### 簡單的 Node.js RESTful API
```bash
sudo apt-get update
sudo apt-get install nodejs
sudo apt-get install npm
mkdir myproject && cd myproject
npm init
npm install express --save
```
index.js
```js
const express = require('express');
const app = express();
app.get('/api', function (req, res) {
person = {"name": "Alice", "age": 30, "city": "Taipei"}
res.send(person);
});
app.listen(3000, function () {
console.log('API listening on port 3000!');
});
```
執行
```bash
node index.js
```
http://localhost:3000/api