В процесе разработки будет создан контроллер, обрабатывающий следующие типы запросов:
Methods | Urls | Actions |
---|---|---|
GET | api/tutorials | get all Tutorials |
GET | api/tutorials/:id | get Tutorial by id |
POST | api/tutorials | add new Tutorial |
PUT | api/tutorials/:id | update Tutorial by id |
DELETE | api/tutorials/:id | remove Tutorial by id |
DELETE | api/tutorials | remove all Tutorials |
GET | api/tutorials/published | find all published Tutorials |
GET | api/tutorials?title=[kw] | find all Tutorials which title contains 'kw' |
Установка приложения и зависимостей приложения:
express npm install express sequelize mysql2 body-parser cors --save
Файл package.json
{ "name": "nodejs-express-sequelize-mysql", "version": "1.0.0", "description": "Node.js Rest Apis with Express, Sequelize & MySQL", "main": "server.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "keywords": [ "nodejs", "express", "rest", "api", "sequelize", "mysql" ], "author": "bezkoder", "license": "ISC", "dependencies": { "body-parser": "^1.19.0", "cors": "^2.8.5", "express": "^4.17.1", "mysql2": "^2.0.2", "sequelize": "^5.21.2" } }