forked from coryhouse/js-dev-env-demo-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
24 lines (19 loc) · 716 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
var express = require('express');
var cors = require('cors');
const app = express();
app.use(cors());
app.set('port', (process.env.PORT || 5000));
app.get('/', function(request, response) {
response.send('Hello World!')
});
app.get('/users', function(req, res) {
// Hard coding for simplicity. Pretend this hits a real database
res.json([
{"id": 1,"firstName":"Bob","lastName":"Smith","email":"[email protected]"},
{"id": 2,"firstName":"Tammy","lastName":"Norton","email":"[email protected]"},
{"id": 3,"firstName":"Tina","lastName":"Lee","email":"[email protected]"}
]);
});
app.listen(app.get('port'), function() {
console.log("Node app is running at localhost:" + app.get('port'));
});