-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
36 lines (25 loc) · 917 Bytes
/
index.js
File metadata and controls
36 lines (25 loc) · 917 Bytes
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
// index.js
// BASE SETUP
// =============================================================================
var express = require('express');
var app = express();
var bodyParser = require('body-parser');
// this will let us get the data from a POST
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
// set our port
var port = process.env.PORT || 8080;
// ROUTES FOR OUR API
// =============================================================================
// get an instance of the express Router
var router = express.Router();
// Home route
router.get('/', function(req, res) {
res.json({ message: 'hooray! welcome to our api!' });
});
// REGISTER ROUTES
app.use('/api', router);
// START THE SERVER
// =============================================================================
app.listen(port);
console.log('Mission Complete listening on port ' + port);