Skip to content

vsb-js/lab-07-example-solution

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lab-07

Description

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.

Tasks

  1. Create npm project using npm init in the folder lab-07-xx. More info here.
  2. Add express, sequelize, and other packages what you need. More info in presenation 5 Express and 6 ORM
    • npm install express --save
    • npm install sequelize --save and npm install --save sqlite3
  3. 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.
  4. ORM scheme (2 models connected via association)
  5. Create 4 endpoints
    1. get all information via one request (from both tables)
    2. get information about one specific item from table
    3. post new item into table
    4. delete item from table
  6. Bonus: Create tests for endpoints with packages jest, supertest

Some tips

  1. Migration should create DB from nothing. Learn how to do it.
  2. Do tasks steps by step. Focus on one thing.
  3. Use documentation, google, stackoverflow
  4. Comment your code!
  5. Format your code! Don't be a messy programmer.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published