akf-forum/index.js

20 lines
755 B
JavaScript
Raw Normal View History

2022-03-22 00:16:47 +03:00
const error = require("./errors/error.js"),
session = require('express-session'),
bodyParser = require('body-parser'),
port = process.env.PORT ?? 3000,
express = require('express'),
fs = require("fs"),
app = express();
2022-03-13 16:16:46 +03:00
app.use(session({ secret: 'secret', resave: true, saveUninitialized: true }));
app.use(bodyParser.urlencoded({ extended: true }));
2022-03-22 00:10:29 +03:00
app.use(express.static("public"));
2022-03-13 16:16:46 +03:00
app.set("view engine", "ejs");
2022-03-22 00:10:29 +03:00
app.use(express.json());
2022-03-13 16:16:46 +03:00
2022-03-22 00:10:29 +03:00
for (const file of fs.readdirSync("./routes"))
2022-03-22 21:25:09 +03:00
app.use("/" + file.replace(".js",""), require(`./routes/${file}`));
2022-03-21 23:53:22 +03:00
2022-03-22 00:10:29 +03:00
app.all("*", (req, res) => error(res, 404, "We have not got this page."));
2022-03-21 23:53:22 +03:00
2022-03-22 00:10:29 +03:00
app.listen(port, () => console.log("Akf-forum on port:", port));