mirror of
https://github.com/Akif9748/akf-forum.git
synced 2024-11-22 20:10:40 +03:00
Akif9748
ae83e014a0
The dublicate key error fixed, ids as string. classes removed. using mongoose's magic
25 lines
No EOL
994 B
JavaScript
25 lines
No EOL
994 B
JavaScript
const error = require("./errors/error.js"),
|
|
session = require('express-session'),
|
|
bodyParser = require('body-parser'),
|
|
port = process.env.PORT || 3000,
|
|
mongoose = require("mongoose"),
|
|
express = require('express'),
|
|
fs = require("fs"),
|
|
app = express();
|
|
|
|
require("dotenv").config();
|
|
mongoose.connect(process.env.MONGO_DB_URL || "mongodb://localhost:27017/akf-forum", () => console.log("Database is connected"));
|
|
|
|
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());
|
|
app.use(require("./middlewares/user"));
|
|
|
|
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)); |