forked from o2nitin/MEAN-STACK-DEMO
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
28 lines (21 loc) · 739 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
var express =require('express');
var app =express();
var bodyParser = require('body-parser');
var mongoose =require('mongoose');
var path = require('path');
var customers = require('./routes/customers');
var invoices =require('./routes/invoices');
//Mongoose Connect
mongoose.connect(process.env.DBPATH);
var db =mongoose.connection;
app.use(express.static(__dirname+ '/client'));
app.use(bodyParser.json());
app.use('/client',express.static(__dirname + '/client'));
app.get('/',function (req,res) {
res.sendFile(path.join(__dirname + '/client/index.html'));
});
app.use('/api/customers',customers);
app.use('/api/invoices',invoices);
var port = process.env.PORT || 3000;
app.listen(port);
console.log('Started on port '+ port);