akf-forum/index.js
2022-03-22 21:25:09 +03:00

20 lines
No EOL
755 B
JavaScript

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();
app.use(session({ secret: 'secret', resave: true, saveUninitialized: true }));
app.use(bodyParser.urlencoded({ extended: true }));
app.use(express.static("public"));
app.set("view engine", "ejs");
app.use(express.json());
for (const file of fs.readdirSync("./routes"))
app.use("/" + file.replace(".js",""), require(`./routes/${file}`));
app.all("*", (req, res) => error(res, 404, "We have not got this page."));
app.listen(port, () => console.log("Akf-forum on port:", port));