-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
44 lines (36 loc) · 1.24 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
39
40
41
42
43
44
import path from 'path'
import express from 'express'
var app = express();
var bodyParser = require('body-parser');
var sass = require('node-sass');
var sassMiddleware = require('node-sass-middleware');
// Static files config setup
app.set('view engine', 'jade');
app.set('views', './public/views');
// Sass middleware for compiling to css
app.use(
sassMiddleware({
src: __dirname + '/public/assets/stylesheets/scss',
dest: __dirname + '/public/assets/stylesheets/css',
force: true,
// debug: true
})
),
// [this line must come after sassMiddleware]
app.use(express.static( path.join( __dirname, 'public' ) ) );
// DB Setup
var mongoose = require('mongoose');
mongoose.connect(process.env.DATABASE_URL);
// mongoose.connect('mongodb://localhost:27017/flatpage');
// POST request form data parser used in routes.js
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
// Routes/endpoint initialization
var routes = require("./routes");
routes(app);
// Start the server on port 3000
var server = app.listen(process.env.PORT || '3000', function () {
var host = server.address().address;
var port = server.address().port;
console.log('App listening at http://localhost:%s', port);
});