-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
34 lines (27 loc) · 764 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
34
const express = require('express');
const app = express();
const mongoose = require('mongoose');
app.use(express.json());
app.use(express.static('public'))
require("dotenv").config();
const mainRouter = require('./routes/index.js');
const toolsRouter = require('./routes/tools.js');
app.use(mainRouter);
app.use(toolsRouter);
mongoose.connect(process.env.MONGODB_URL + '/live');
app.set("view engine", "ejs");
const PORT = process.env.PORT || 3000;
app.listen(PORT, () => {
console.log(`working on ${PORT}`);
});
app.use((req, res, next) => {
res.status(404).render("broken.ejs", {
code: "404"
})
})
app.use((err, req, res, next) => {
console.error(err.stack)
res.status(500).render("broken.ejs", {
code: "500"
})
})