You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
798 B
35 lines
798 B
import express, { NextFunction, Request, Response } from 'express';
|
|
import ejsMate from 'ejs-mate';
|
|
import router from './router';
|
|
|
|
const { PORT = 3000 } = process.env;
|
|
|
|
const app = express();
|
|
|
|
app.engine('ejs', ejsMate);
|
|
app.set('views', '/opt/app/views');
|
|
app.set('view engine', 'ejs');
|
|
|
|
app.use(router.router);
|
|
|
|
app.use('/dist/bootstrap', express.static('/opt/app/public'));
|
|
|
|
app.use(express.static('/opt/app/public'));
|
|
|
|
app.use((req: Request, res: Response, next: NextFunction) => {
|
|
// 404
|
|
return next(new Error('404'));
|
|
});
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
app.use((err, req: Request, res: Response, next: NextFunction) => {
|
|
// 404
|
|
res.render('error');
|
|
});
|
|
|
|
app.listen(PORT, () => {
|
|
console.log(
|
|
`application is listening on port ${PORT}`,
|
|
);
|
|
});
|