feat: initial Papo bot scaffold
This commit is contained in:
32
src/web/server.ts
Normal file
32
src/web/server.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
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;
|
||||
}
|
||||
Reference in New Issue
Block a user