Skip to content

Instantly share code, notes, and snippets.

@HowardOhMyGod
Created June 3, 2018 08:02
Show Gist options
  • Select an option

  • Save HowardOhMyGod/f071811e22729500d81271e41e0cee5f to your computer and use it in GitHub Desktop.

Select an option

Save HowardOhMyGod/f071811e22729500d81271e41e0cee5f to your computer and use it in GitHub Desktop.
const express = require('express');
const bodyParser = require('body-parser');
var app = express();
// parse setting
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: false}));
app.get('/api', (req, res) => {
res.status(200).send({
message: "Welcome to CI/CD!",
success: true
});
});
app.get('/api/books', (req, res) => {
res.status(200).send({
books: [{
title: "Herry Potter",
author: "JK"
}, {
title: "Book1",
author: "JJ"
},{
title: "Book2",
author: "JJ2"
}],
success: true
});
});
app.listen(3000, (err) => {
console.log('Server listen on port 3000...');
});
// for testing
module.exports = app
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment