This repository was archived by the owner on Dec 21, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
53 lines (43 loc) · 1.63 KB
/
Copy pathserver.js
File metadata and controls
53 lines (43 loc) · 1.63 KB
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
45
46
47
48
49
50
51
52
53
/**
* Created by Ale on 08.12.2014.
*/
// call the packages we need
var express = require('express');
var app = express();
var bodyParser = require('body-parser');
// set the static files location /public/img will be /img for users
app.use(express.static(__dirname + '/public'));
// configure app to use bodyParser()
// this will let us get the data from a POST
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
// Put this somewhere else
require('./app/models/changelog');
// --------------------------------------------------------
// ROUTES CONFIGURATION
// Get an instance of the express Router
var router = express.Router();
// Routes for caregivers
require('./app/routes/caregivers')(router);
// Routes for services
require('./app/routes/services')(router);
// Routes for customers
require('./app/routes/customers')(router);
// Routes for changelog
require('./app/routes/changelog')(router);
// Register the router (prefixed with /api)
app.use('/api', router);
// --------------------------------------------------------
// DATABASE CONNECTION
var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost:27017/careapp'); // connect to our database
// application -------------------------------------------------------------
app.get('*', function(req, res) {
// load the single view file (angular will handle the page changes on the front-end)
res.sendFile('./public/index.html');
});
// START THE SERVER
// =============================================================================
var port = process.env.PORT || 8080; // set our port
app.listen(port);
console.log('Connected on port ' + port);