init
This commit is contained in:
1 parent
b9d2f99c3b
commit
ed58376600
18 files changed
+2349
-2
No files matched your search
@@ -0,0 +1,37 @@
|
||||
// server.js
|
||||
require('dotenv').config();
|
||||
const express = require('express');
|
||||
const path = require('path');
|
||||
const morgan = require('morgan');
|
||||
const bodyParser = require('body-parser');
|
||||
|
||||
const indexRouter = require('./routes/index');
|
||||
|
||||
const app = express();
|
||||
const PORT = process.env.PORT || 3000;
|
||||
|
||||
// View engine
|
||||
app.set('view engine', 'ejs');
|
||||
app.set('views', path.join(__dirname, 'views'));
|
||||
|
||||
// Middleware
|
||||
app.use(express.static(path.join(__dirname, 'public')));
|
||||
app.use(bodyParser.urlencoded({ extended: true }));
|
||||
app.use(bodyParser.json());
|
||||
app.use(morgan('dev'));
|
||||
|
||||
// Routes
|
||||
app.use('/', indexRouter);
|
||||
|
||||
// Error handler
|
||||
app.use((err, req, res, next) => {
|
||||
console.error(err);
|
||||
res.status(500).render('error', {
|
||||
message: 'Internal Server Error',
|
||||
detail: err.message
|
||||
});
|
||||
});
|
||||
|
||||
app.listen(PORT, () =>
|
||||
console.log(`Proxer-Downloader running on http://localhost:${PORT}`)
|
||||
);
|
||||
Reference in new issue
Block a user