Express によるアプリケーション開発
5 章からは Express.js を使って ToDo アプリケーションを開発する。
ディレクトリを作成し、その中で npm init -y
npm init
のドキュメント
$ mkdir todo-express && cd $_ && npm init -y { "name": "todo-express", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "keywords": [], "author": "", "license": "ISC" }
"scripts": { "start": "node app" },
Experss.js
Fast, unopinionated, minimalist web framework for node.
unopinionated の意味は「柔軟な」ですかね?
サポートリポジトリでは、バージョン 4.17.1
をインストールしている。
https://github.com/oreilly-japan/hands-on-nodejs/blob/master/ch05/todo-express/package.json
2020 年 12 月末現時点での最新バージョンを利用している。
$ npm i express@4.17.1
app.js
を作成。
ターミナルにて $ npm start
。ブラウザで http://localhost:3000/api/todos
を開くと
[{"id":1,"title":"ネーム","completed":false},{"id":2,"title":"下書き","completed":false}]
と表示された。