added withOptionalAuthentication middleware

This commit is contained in:
srgooglo 2022-09-09 18:57:31 +02:00
parent ff5f156ed0
commit adeb82629e
2 changed files with 11 additions and 0 deletions

View File

@ -1,6 +1,8 @@
// const fileUpload = require("@nanoexpress/middleware-file-upload/cjs")() // const fileUpload = require("@nanoexpress/middleware-file-upload/cjs")()
export { default as withAuthentication } from "./withAuthentication" export { default as withAuthentication } from "./withAuthentication"
export { default as withOptionalAuthentication } from "./withOptionalAuthentication"
export { default as errorHandler } from "./errorHandler" export { default as errorHandler } from "./errorHandler"
export { default as hasPermissions } from "./hasPermissions" export { default as hasPermissions } from "./hasPermissions"
export { default as roles } from "./roles" export { default as roles } from "./roles"

View File

@ -0,0 +1,9 @@
import withAuthentication from "../withAuthentication"
export default (req, res, next) => {
if (req.headers?.authorization) {
withAuthentication(req, res, next)
} else {
next()
}
}