-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
48 lines (43 loc) · 1.4 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import express from 'express';
import session from 'express-session';
import { engine } from 'express-handlebars';
import path from 'path';
import { homeRouter } from './routers/home';
import { registerRouter } from './routers/register';
import { mineRouter } from './routers/mine';
import { loginRouter } from './routers/login';
import { profileRouter } from './routers/profile';
import { logoutRouter } from './routers/logout';
import { recruitRouter } from './routers/recruit';
import { buildRouter } from './routers/build';
const app = express();
app.use(session({
secret: 'RainbowChestsAreSuperior',
resave: false,
saveUninitialized: true,
cookie: {maxAge: 1000 * 60 * 60 * 24},
}));
app.use(express.json());
app.use(express.urlencoded({
extended: true,
}));
app.use(express.static('public'));
app.engine('.hbs', engine({
extname: '.hbs',
partialsDir: path.join(__dirname, 'views/partials'),
helpers: {
deleteInterval: (interval: NodeJS.Timer) => {
clearInterval(interval);
}
}
}));
app.set('view engine', '.hbs');
app.use('/', homeRouter);
app.use('/register', registerRouter);
app.use('/login', loginRouter);
app.use('/logout', logoutRouter);
app.use('/profile', profileRouter);
app.use('/build', buildRouter);
app.use('/mine', mineRouter);
app.use('/recruit', recruitRouter)
app.listen(3000, '0.0.0.0', () => console.log(`listening on http://localhost:3000`));