-
Notifications
You must be signed in to change notification settings - Fork 9
/
app.js
38 lines (35 loc) · 1.13 KB
/
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
27
28
29
30
31
32
33
34
35
36
37
38
/*
* Project Name: 4chan NodeJS
* Written by Daniel <daniel.reguero@hotmail.com>
*/
//Import our Modules
var express = require('express'),
app = express(),
bodyParser = require('body-parser');
require('dotenv').config();
var config = require("./config");
var Boards = require("./models/boards");
var Threads = require("./models/threads");
var Comments = require("./models/comments");
//Seed our database.
console.log("Seeding ...");
config.seedDatabase(Boards, Comments, Threads, app);
//var middlewares = require("./middlewares");
//'Custom' modules/variables.
var port = process.env.PORT || 3000;
var indexController = require("./controllers");
var boardController = require("./controllers/boards");
// Begin Middleware
app.use('/assets', express.static(__dirname + "/public"));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({
extended: true
}));
app.set('view engine', 'ejs');
//Call in our controllers/routes
indexController(app);
boardController(app, Boards, Threads, Comments);
//Listen on port specified.
app.listen(port, function(){
console.log("Website is running on http://" + process.env.HOST + ":" + port);
});