feat: add base implementation for realtime communication

Signed-off-by: Philip Molares <philip.molares@udo.edu>
Signed-off-by: Erik Michelson <github@erik.michelson.eu>
Co-authored-by: Erik Michelson <github@erik.michelson.eu>
Co-authored-by: Philip Molares <philip.molares@udo.edu>
Co-authored-by: Tilman Vatteroth <git@tilmanvatteroth.de>
Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
Tilman Vatteroth 2022-04-02 23:45:46 +02:00 committed by David Mehren
parent d9ef44766d
commit ce29cc0a2e
44 changed files with 2151 additions and 65 deletions

View file

@ -1,36 +0,0 @@
/*
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { NestExpressApplication } from '@nestjs/platform-express';
import { ConsoleLoggerService } from '../logger/console-logger.service';
import { useUnless } from './use-unless';
export async function setupFrontendProxy(
app: NestExpressApplication,
logger: ConsoleLoggerService,
): Promise<void> {
logger.log(
`Setting up proxy to frontend dev server on port 3001`,
'setupFrontendProxy',
);
const createProxyMiddleware = (await import('http-proxy-middleware'))
.createProxyMiddleware;
const frontendProxy = createProxyMiddleware({
logProvider: () => {
return {
log: (msg) => logger.log(msg, 'FrontendProxy'),
debug: (msg) => logger.debug(msg, 'FrontendProxy'),
info: (msg) => logger.log(msg, 'FrontendProxy'),
warn: (msg) => logger.warn(msg, 'FrontendProxy'),
error: (msg) => logger.error(msg, 'FrontendProxy'),
};
},
target: 'http://localhost:3001',
changeOrigin: true,
ws: true,
});
app.use(useUnless(['/api', '/public'], frontendProxy));
}