forked from holive/quepid-like
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
26 lines (21 loc) · 875 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
const db = require("mongoose");
const path = require("path");
const express = require("express");
const app = require("express")();
const expressLayouts = require("express-ejs-layouts");
const bodyParser = require("body-parser");
const routes = require("./routes");
// view engine setup
app.set("views", path.join(__dirname, "views"));
app.set("view engine", "ejs");
app.use(expressLayouts);
app.use(express.static(__dirname + "/public"));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true })); // support encoded bodies
app.use("/", routes);
// mongo
db.connect("mongodb://localhost:27017/test", { useNewUrlParser: true });
db.connection.on("error", console.error.bind(console, "connection error:"));
db.set("useCreateIndex", true);
//FIXME: share and use the same db instance
app.listen(3000, () => console.log("App listening on port 3000"));