-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
33 lines (26 loc) · 884 Bytes
/
app.js
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
import express from 'express';
import fileUpload from 'express-fileupload';
import logger from 'morgan';
import cookieParser from 'cookie-parser';
import path from 'path';
import { router as patternRouter } from './routes/pattern.js';
import { router as indexRouter } from './routes/index.js';
export const app = express();
// view engine setup
app.set('views', path.join(process.cwd(), 'views'));
app.set('view engine', 'hbs');
app.use(logger('dev'));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(process.cwd(), 'client/build')));
app.use(fileUpload());
app.use((req, res, next) => {
res.locals.isDevelopment = req.app.get('env') === 'development';
next();
});
app.use('/pattern', patternRouter);
app.use('/', indexRouter);
app.use('*', (req, res) => {
res.redirect('/');
});