mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-15 15:44:45 -04:00
fix(repository): Move backend code into subdirectory
Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
parent
86584e705f
commit
bf30cbcf48
272 changed files with 87 additions and 67 deletions
37
backend/src/utils/session.ts
Normal file
37
backend/src/utils/session.ts
Normal file
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
import { INestApplication } from '@nestjs/common';
|
||||
import { TypeormStore } from 'connect-typeorm';
|
||||
import session from 'express-session';
|
||||
|
||||
import { AuthConfig } from '../config/auth.config';
|
||||
|
||||
export const HEDGEDOC_SESSION = 'hedgedoc-session';
|
||||
|
||||
/**
|
||||
* Set up the session middleware via the given authConfig.
|
||||
* @param {INestApplication} app - the nest application to configure the middleware for.
|
||||
* @param {AuthConfig} authConfig - the authConfig to configure the middleware with.
|
||||
* @param {TypeormStore} typeormStore - the typeormStore to handle session data.
|
||||
*/
|
||||
export function setupSessionMiddleware(
|
||||
app: INestApplication,
|
||||
authConfig: AuthConfig,
|
||||
typeormStore: TypeormStore,
|
||||
): void {
|
||||
app.use(
|
||||
session({
|
||||
name: HEDGEDOC_SESSION,
|
||||
secret: authConfig.session.secret,
|
||||
cookie: {
|
||||
maxAge: authConfig.session.lifetime,
|
||||
},
|
||||
resave: false,
|
||||
saveUninitialized: false,
|
||||
store: typeormStore,
|
||||
}),
|
||||
);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue