multi-account-post-schedule.../app.js

50 lines
1.4 KiB
JavaScript
Raw Normal View History

2023-07-03 23:12:20 +02:00
let createError = require('http-errors');
let express = require('express');
let path = require('path');
let cookieParser = require('cookie-parser');
let logger = require('morgan');
2022-07-07 18:23:44 +02:00
2023-07-03 23:12:20 +02:00
let indexRouter = require('./routes/index');
let usersRouter = require('./routes/users');
2022-07-07 18:23:44 +02:00
const listenPort = 8000;
2023-07-03 23:12:20 +02:00
let app = express();
2022-07-07 18:23:44 +02:00
// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'jade');
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('/users', usersRouter);
// catch 404 and forward to error handler
app.use(function(req, res, next) {
next(createError(404));
});
// error handler
app.use(function(err, req, res, next) {
// set locals, only providing error in development
res.locals.message = err.message;
res.locals.error = req.app.get('env') === 'development' ? err : {};
// render the error page
res.status(err.status || 500);
res.render('error');
});
module.exports = app;
app.listen(listenPort, () => console.log(`Server is live at http://localhost:${listenPort}`));
console.log('=================================================================');
2023-03-04 10:30:20 +01:00
console.log('= made by Tykayn from CipherBliss - https://mastodon.cipherbliss.com/@tykayn');
2022-07-07 18:23:44 +02:00
console.log('=================================================================');