-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
35 lines (27 loc) · 960 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
27
28
29
30
31
32
33
34
35
var express = require('express');
var path = require('path');
var logger = require('morgan');
var bodyParser = require('body-parser');
var cors = require('cors');
var config = require('./config/config');
// Connect to MongoDb
var mongoose = require('mongoose');
mongoose.connect(config.database, function(err) {
if (err) throw err;
console.log('Successfully connected to MongoDB');
});
var app = express();
app.use(cors());
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
// Init static directories
app.use(express.static(__dirname+'/client'));
app.set('superSecret', config.secret); // secret variable
// Routes
app.use('/api', require('./routes/index'));
app.use('/api/users', require('./routes/users'));
app.use('/api/auth', require('./routes/auth'));
app.use('/api/timetables', require('./routes/timetable'));
app.use('/api/events', require('./routes/event'));
module.exports = app;