- 創建專案
npm init
- 安裝程式
npm i express
- index.js
const express = require('express');
const app = express();
const conf = require("./config");
app.get('/', function (req, res) {
res.send('Hello World!');
});
app.listen(conf.port, function () {
console.log(`server start on http://localhost:${conf.port}`);
});
- config.js
module.exports = {
// bind the port of service
port: 3000
};
RESTFul 設計參考 https://tw.alphacamp.co/blog/rest-restful-api
API
Order | Method | URI | parameter | result |
---|---|---|---|---|
1 | GET | |||
2 | ||||