wip(backend): Started work on v3 backend
This commit is contained in:
parent
94f0ca0e0b
commit
88d9b2a1e9
67 changed files with 1375 additions and 2842 deletions
28
sites/backend/src/middleware.mjs
Normal file
28
sites/backend/src/middleware.mjs
Normal file
|
@ -0,0 +1,28 @@
|
|||
//import bodyParser from 'body-parser'
|
||||
import cors from 'cors'
|
||||
import jwt from 'passport-jwt'
|
||||
|
||||
function loadExpressMiddleware(app) {
|
||||
// FIXME: Is this still needed in FreeSewing v3?
|
||||
//app.use(bodyParser.urlencoded({ extended: true }))
|
||||
app.use(cors())
|
||||
}
|
||||
|
||||
function loadPassportMiddleware(passport, config) {
|
||||
passport.use(
|
||||
new jwt.Strategy(
|
||||
{
|
||||
jwtFromRequest: jwt.ExtractJwt.fromAuthHeaderAsBearerToken(),
|
||||
...config.jwt,
|
||||
},
|
||||
(jwt_payload, done) => {
|
||||
return done(null, jwt_payload)
|
||||
}
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
export {
|
||||
loadExpressMiddleware,
|
||||
loadPassportMiddleware,
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue