mirror of
https://github.com/Akif9748/akf-forum.git
synced 2024-11-23 04:10:40 +03:00
Main page changed from /index to /
This commit is contained in:
parent
e0d427ac4b
commit
32740a65c4
2 changed files with 10 additions and 24 deletions
34
index.js
34
index.js
|
@ -1,34 +1,20 @@
|
||||||
const express = require('express');
|
const error = require("./errors/error.js");
|
||||||
const bodyParser = require('body-parser');
|
|
||||||
const path = require("path");
|
|
||||||
const fs = require("fs");
|
|
||||||
const session = require('express-session');
|
const session = require('express-session');
|
||||||
const error = require("./errors/error.js")
|
const bodyParser = require('body-parser');
|
||||||
|
const express = require('express');
|
||||||
|
const fs = require("fs");
|
||||||
const app = express();
|
const app = express();
|
||||||
|
|
||||||
app.use(session({ secret: 'secret', resave: true, saveUninitialized: true }));
|
app.use(session({ secret: 'secret', resave: true, saveUninitialized: true }));
|
||||||
app.use(express.static("public"));
|
|
||||||
app.use(bodyParser.urlencoded({ extended: true }));
|
app.use(bodyParser.urlencoded({ extended: true }));
|
||||||
|
app.use(express.static("public"));
|
||||||
|
app.set("view engine", "ejs");
|
||||||
app.use(express.json());
|
app.use(express.json());
|
||||||
|
|
||||||
app.set('views', path.join(__dirname, 'views'));
|
for (const file of fs.readdirSync("./routes"))
|
||||||
app.set("view engine", "ejs");
|
app.use("/" + file.slice(0, -3), require(`./routes/${file}`));
|
||||||
|
|
||||||
//Temp:
|
app.all("*", (req, res) => error(res, 404, "We have not got this page."));
|
||||||
app.get("/", (req, res) => res.redirect("/index"));
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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."))
|
|
||||||
const port = process.env.PORT || 3000;
|
const port = process.env.PORT || 3000;
|
||||||
|
app.listen(port, () => console.log("Akf-forum on port:", port));
|
||||||
app.listen(port, () => console.log("SERVER ON PORT:", port));
|
|
||||||
|
|
Loading…
Reference in a new issue