fix(repository): Move backend code into subdirectory

Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
Tilman Vatteroth 2022-10-02 20:10:32 +02:00 committed by David Mehren
parent 86584e705f
commit bf30cbcf48
272 changed files with 87 additions and 67 deletions

View 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,
}),
);
}