AUTHKEY
This commit is contained in:
parent
56ebf652b1
commit
642e141abd
@ -5,4 +5,5 @@ SMTP_PASS="secret.1"
|
||||
EMAIL_FROM="noreply@lauf-fuer-kaya.de"
|
||||
EMAIL_REPLYTO="info@lauf-fuer-kaya.de"
|
||||
REDIS_URL=redis://localhost:6379
|
||||
FRONTEND_URL="https://run.lauf-fuer-kaya.de"
|
||||
FRONTEND_URL="https://run.lauf-fuer-kaya.de"
|
||||
AUTHKEY=""
|
@ -9,6 +9,10 @@ const app = new Hono()
|
||||
app.use('*', logger())
|
||||
app.use('*', prettyJSON())
|
||||
|
||||
if ((process.env.AUTHKEY || "") === "") {
|
||||
console.warn("process.env.AUTHKEY was not provided!");
|
||||
}
|
||||
|
||||
app.route('/api/v1/email', emailRouter)
|
||||
app.get('/docs', createSwaggerUI())
|
||||
app.get('/swagger', createSwaggerUI())
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { Hono } from 'hono'
|
||||
import { bearerAuth } from 'hono/bearer-auth'
|
||||
import { zValidator } from '@hono/zod-validator'
|
||||
import { z } from 'zod'
|
||||
import { EmailService } from '../services/email'
|
||||
@ -32,7 +33,7 @@ async function generateBarcodeDataURL(data) {
|
||||
return dataURL;
|
||||
}
|
||||
|
||||
emailRouter.post('/', zValidator('json', sendEmailSchema), async (c) => {
|
||||
emailRouter.post('/', bearerAuth({ token: process.env.AUTHKEY }),zValidator('json', sendEmailSchema), async (c) => {
|
||||
let { to, templateName, language, data } = c.req.valid('json')
|
||||
|
||||
try {
|
||||
@ -67,7 +68,7 @@ emailRouter.post('/', zValidator('json', sendEmailSchema), async (c) => {
|
||||
})
|
||||
|
||||
// Add queue status endpoint
|
||||
emailRouter.get('/status', async (c) => {
|
||||
emailRouter.get('/status', bearerAuth({ token: process.env.AUTHKEY }),async (c) => {
|
||||
try {
|
||||
const status = await emailService.getQueueStatus()
|
||||
return c.json(status)
|
||||
|
Loading…
x
Reference in New Issue
Block a user