mirror of
https://github.com/Raghu-Ch/nodeRestAPI.git
synced 2026-02-10 04:33:03 -05:00
initial commit
This commit is contained in:
29
server.js
Normal file
29
server.js
Normal file
@@ -0,0 +1,29 @@
|
||||
var express = require('express');
|
||||
var bodyParser = require('body-parser');
|
||||
var fs = require('fs');
|
||||
var app = express();
|
||||
|
||||
var router = express.Router();
|
||||
|
||||
var port = process.env.PORT || 4000;
|
||||
|
||||
router.route('/Beards')
|
||||
.get(function (req, res) {
|
||||
var beards = fs.readFileSync("beardstyles.json");
|
||||
var beardstyles = JSON.parse(beards);
|
||||
|
||||
res.send(beardstyles);
|
||||
});
|
||||
|
||||
router.get('/', function (req, res) {
|
||||
|
||||
res.send({ hello: "Welcome to our API" });
|
||||
|
||||
});
|
||||
//ROUTER REGISTERING
|
||||
// all routes will be prefixed with /api
|
||||
app.use('/api', router);
|
||||
|
||||
app.listen(port, function () {
|
||||
console.log("Gulp is up & running on port:" + port);
|
||||
});
|
||||
Reference in New Issue
Block a user