33 lines
873 B
TypeScript
33 lines
873 B
TypeScript
import express from 'express';
|
|
import session from 'express-session';
|
|
import cookieParser from 'cookie-parser';
|
|
import path from 'path';
|
|
import authRouter from './routes/auth.js';
|
|
import dashboardRouter from './routes/dashboard.js';
|
|
import apiRouter from './routes/api.js';
|
|
import { env } from '../config/env.js';
|
|
|
|
export function createWebServer() {
|
|
const app = express();
|
|
app.use(express.json());
|
|
app.use(cookieParser());
|
|
app.use(
|
|
session({
|
|
secret: env.sessionSecret,
|
|
resave: false,
|
|
saveUninitialized: false
|
|
})
|
|
);
|
|
|
|
app.use('/auth', authRouter);
|
|
app.use('/dashboard', dashboardRouter);
|
|
app.use('/api', apiRouter);
|
|
|
|
app.get('/', (_req, res) => {
|
|
res.send(`<h1>Papo Dashboard</h1><p><a href="/dashboard">Zum Dashboard</a></p>`);
|
|
});
|
|
|
|
app.use('/static', express.static(path.join(process.cwd(), 'static')));
|
|
return app;
|
|
}
|