-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
28 lines (23 loc) · 961 Bytes
/
index.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 bodyParser = require('body-parser');
require('dotenv').config();
var path = require('path');
var async = require('async');
var app = express();
var Country = require('./models/countries');
var morgan = require('morgan');
var mongoose = require('mongoose');
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(express.static(path.join(__dirname, 'public')));
app.use(morgan('dev'));
mongoose.connect("mongodb://heroku_rr89r5q3:[email protected]:55811/heroku_rr89r5q3" || /mongodb://localhost/whatdoyou);
Country.find({}, function(err ,response){
console.log(JSON.stringify(response));
});
app.use('/api/countries', require('./controllers/countries'));
app.use('/api/articles', require('./controllers/articles'));
app.get('/*', function(req, res) {
res.sendFile(path.join(__dirname, 'public/index.html'));
});
app.listen(process.env.PORT || 3000);