chore: ingest source code

58 files from https://github.com/gothinkster/node-express-realworld-example-app
This commit is contained in:
2026-03-13 11:38:49 +00:00
commit 1d0b844e76
58 changed files with 12898 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
import { expressjwt as jwt } from 'express-jwt';
import * as express from 'express';
const getTokenFromHeaders = (req: express.Request): string | null => {
if (
(req.headers.authorization && req.headers.authorization.split(' ')[0] === 'Token') ||
(req.headers.authorization && req.headers.authorization.split(' ')[0] === 'Bearer')
) {
return req.headers.authorization.split(' ')[1];
}
return null;
};
const auth = {
required: jwt({
secret: process.env.JWT_SECRET || 'superSecret',
getToken: getTokenFromHeaders,
algorithms: ['HS256'],
}),
optional: jwt({
secret: process.env.JWT_SECRET || 'superSecret',
credentialsRequired: false,
getToken: getTokenFromHeaders,
algorithms: ['HS256'],
}),
};
export default auth;