Skip to content

Latest commit

 

History

History
67 lines (56 loc) · 2.79 KB

File metadata and controls

67 lines (56 loc) · 2.79 KB

Debug in Node.js

For this task you will use this template repository. You have to create repository from that repo and send solution into it.

Prerequisites

  1. Install Postgres (contains pgAdmin4)
  2. Postgres should work on localhost, on 5433 port
  3. Create user
  4. Run pgAdmin4
  5. Create database with name gamedb
    debug-1_link
    debug-2_link
  6. In file db.js change username and password strings to yours (DO NOT COMMIT THIS)
    debug-3_link
  7. Install dependencies (npm i)
  8. Run application via npm run start

Alternative way to use Postgres (via ElephantSQL API)

  1. Go to ElephantSQL website and register debug_alt-1_link
  2. Use any team name, agree with terms of service check that you don't need to follow GDPR
    debug_alt-2_link
  3. Press button "Create new Instance"
    debug_alt-3_link
  4. Give instance name & select free plan ("Tiny turtle")
    debug_alt-4_link
  5. Choose region AWS eu-west-1 (or eu-central-1)
    debug_alt-5_link
  6. Confirm creation of the instance
    debug_alt-6_link
  7. Click on the instance to see details
    debug_alt-7_link
  8. In the details window necessary properties are:
  • server (host)
  • user & default database
  • password
    debug_alt-8_link (alternatively - use URL).
  1. Install dotenv package (some info) and in .env file (should be in root) set following variables:
DB_HOST=tai.db.elephantsql.com
DB=yourdatabasename
DB_USER=yourusername
DB_PASSWORD=yourpassword
  1. db.js file beginning should look like this:
const Sequelize = require('sequelize');
require('dotenv').config();

const sequelize = new Sequelize(process.env.DB, process.env.DB_USER, process.env.DB_PASSWORD, {
    host: process.env.DB_HOST,
    dialect: 'postgres'
})

DO NOT COMMIT .env file! (add it into .gitignore)

Your task is to find at least 5 compilation errors and 5 logic errors using the debugging tools.

You need fix them and make the broken application workable.

An additional task is to refactor the repository using modern Javascript syntax and fix codestyle issues.