mirror of
https://github.com/myfatemi04/wheelshare-old-backend.git
synced 2025-04-21 12:10:17 -04:00
16 lines
369 B
TypeScript
16 lines
369 B
TypeScript
import { RequestHandler } from 'express';
|
|
import { getSessionByToken } from './auth';
|
|
import getSessionID from './getSessionID';
|
|
|
|
export const sessionMiddleware: RequestHandler = async (req, res, next) => {
|
|
const token = getSessionID(req);
|
|
|
|
if (token != null) {
|
|
req.session = getSessionByToken(token);
|
|
} else {
|
|
req.session = { accountID: null };
|
|
}
|
|
|
|
next();
|
|
};
|