Created
June 3, 2018 08:02
-
-
Save HowardOhMyGod/f071811e22729500d81271e41e0cee5f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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