Skip to content

Commit

Permalink
fix: helpers format modify
Browse files Browse the repository at this point in the history
  • Loading branch information
huanghanzhilian committed Jan 24, 2024
1 parent 6076b1c commit 9a8ade0
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion helpers/api/api-handler.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NextRequest, NextResponse } from 'next/server'
import { NextResponse } from 'next/server'

import { errorHandler, jwtMiddleware, validateMiddleware, identityMiddleware } from '.'

Expand Down
4 changes: 2 additions & 2 deletions helpers/api/error-handler.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { NextResponse } from 'next/server'
import { setJson } from './set-json'

export { errorHandler }

function errorHandler(err) {
if (typeof err === 'string') {
// custom application error
Expand Down Expand Up @@ -48,3 +46,5 @@ function errorHandler(err) {
{ status: 500 }
)
}

export { errorHandler }
4 changes: 2 additions & 2 deletions helpers/api/jwt-middleware.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { auth } from '../'

export { jwtMiddleware }

async function jwtMiddleware(req, isJwt = false) {
const id = await auth.verifyToken(req, isJwt)
req.headers.set('userId', id)
}

export { jwtMiddleware }
6 changes: 2 additions & 4 deletions helpers/api/validate-middleware.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
import joi from 'joi'

export { validateMiddleware }

async function validateMiddleware(req, schema) {
if (!schema) return

Expand All @@ -21,3 +17,5 @@ async function validateMiddleware(req, schema) {
// update req.json() to return sanitized req body
req.json = () => value
}

export { validateMiddleware }

0 comments on commit 9a8ade0

Please sign in to comment.