mirror of
https://github.com/tomru/pfadi-bussle.git
synced 2026-03-03 06:27:11 +01:00
add trigger route
This commit is contained in:
3
.github/workflows/mailtrigger.yaml
vendored
3
.github/workflows/mailtrigger.yaml
vendored
@@ -9,5 +9,4 @@ jobs:
|
||||
- name: Trigger Mail API route
|
||||
run: |
|
||||
curl --request POST \
|
||||
--url 'https://pfadi-bussle.tomru.space/api/mailtrigger' \
|
||||
--header 'Authorization: Bearer ${{ secrets.MAIL_TRIGGER_API_SECRET_KEY }}'
|
||||
--url 'https://pfadi-bussle-dev.tomru.space/api/mailtrigger'
|
||||
|
||||
19
pages/api/mailtrigger.ts
Normal file
19
pages/api/mailtrigger.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { log } from '../../helpers/log'
|
||||
import { NextApiRequest, NextApiResponse } from 'next'
|
||||
|
||||
export default async function useHandler(
|
||||
req: NextApiRequest,
|
||||
res: NextApiResponse
|
||||
): Promise<void> {
|
||||
const { method } = req
|
||||
|
||||
switch (method) {
|
||||
case 'GET':
|
||||
log.info('sending mail triggered')
|
||||
res.statusCode = 200
|
||||
break
|
||||
default:
|
||||
res.setHeader('Allow', ['GET'])
|
||||
res.status(405).end(`Method ${method} Not Allowed`)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user