Skip to content

Commit

Permalink
20240314
Browse files Browse the repository at this point in the history
  • Loading branch information
taichunmin committed Mar 14, 2024
1 parent 19e80c0 commit 6eef366
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 1 deletion.
File renamed without changes.
5 changes: 5 additions & 0 deletions api/notFound.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const createError = require('http-errors')

module.exports = async (ctx, next) => {
throw createError(404)
}
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ const { middlewareCompose } = require('./libs/helper')
const functions = require('@google-cloud/functions-framework')

const handlers = middlewareCompose([
require('./cors'),
require('./api/cors'),
require('./api/index'),
require('./line/handler/index'),
require('./api/notFound'),
])

functions.http('main', async (req, res) => {
Expand Down
1 change: 1 addition & 0 deletions line/handler/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const lineEventHander = middlewareCompose([

module.exports = async (ctx, next) => {
const { req, res } = ctx
if (req.method !== 'POST' || _.isNil(req.get('x-line-signature'))) return await next()
try {
// 處理 access token
const channelAccessToken = req.path.substring(1)
Expand Down

0 comments on commit 6eef366

Please sign in to comment.