You know a lot of information from previous labs, so now you can shine and show yourself. You can use some data from free API - and use it to fill your DB.
The goal of this lab is to try-out things you will need for your project. Try to progress as much as possible so you have time to ask your teacher in case something doesn't work for you.
- Create
npm project
usingnpm init
in the folderlab-07-xx
. More info here. - Add
express
,sequelize
, and other packages what you need. More info in presenation 5 Express and 6 ORMnpm install express --save
npm install sequelize --save
andnpm install --save sqlite3
- Create migration for database
- Follow the guide ^^
- After you init your project. Change the
config.json
to used sqlite with this config:{ "development": { "dialect": "sqlite", "storage": "./db.sqlite" }, "test": { "dialect": "sqlite", "storage": "./db.test.sqlite" }, "production": { "dialect": "sqlite", "storage": "./db.sqlite" } }
- Follow the guide with creating a first migration and run it as per tutorial
- If you want, you can see your database using several DB management tools. VSC has plugins, WebStorm has plugins or you can use for example this.
- ORM scheme (2 models connected via association)
- Create 4 endpoints
- get all information via one request (from both tables)
- get information about one specific item from table
- post new item into table
- delete item from table
- Bonus: Create tests for endpoints with packages
jest
,supertest
- Migration should create DB from nothing. Learn how to do it.
- Do tasks steps by step. Focus on one thing.
- Use
documentation
,google
,stackoverflow
- Comment your code!
- Format your code! Don't be a messy programmer.