This repository has been archived by the owner on Nov 17, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
51 lines (43 loc) · 1.58 KB
/
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
var createError = require('http-errors');
var express = require('express');
var path = require('path');
var cookieParser = require('cookie-parser');
var logger = require('morgan');
var indexRouter = require('./routes/index');
var libraryRouter = require('./routes/library');
var addGameRouter = require('./routes/add');
var identifyRouter = require('./routes/identify');
var platformsRouter = require('./routes/platforms');
var amiiboRouter = require('./routes/amiibo');
var retailersRouter = require('./routes/retailers');
var wishlistRouter = require('./routes/wishlist');
var apiRouter = require('./routes/api');
var app = express();
// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');
app.use(logger('dev'));
app.use(express.json());
app.use(express.urlencoded({extended: false}));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));
app.use('/', indexRouter);
app.use('/library', libraryRouter);
app.use('/add', addGameRouter);
app.use('/identify', identifyRouter);
app.use('/platforms', platformsRouter);
app.use('/amiibo', amiiboRouter);
app.use('/retailers', retailersRouter);
app.use('/wishlist', wishlistRouter);
app.use('/api', apiRouter);
// catch 404 and forward to error handler
app.use(function (req, res, next) {
res.status(404);
res.render('404', {title: 'Pixel Shelf', type: 'page'});
});
// error handler
app.use(function (err, req, res, next) {// render the error page
res.status(err.status || 500);
res.render('error', {status: err.status || 500, message: err.message});
});
module.exports = app;