Coder Social home page Coder Social logo

week7-test's Introduction

week7-test

Tasks:

This test build up on the week 6 test, where only signed in user will be able to add a city and get the cities.

Setting the project

*In this task you need to restructure the database because we are going to change the user schema, follow these steps to get it done. If you stucked in one of them ask any of the mentors

  • clone this repo
  • create config.env file
  • Add the database url in the config.env as DB_URL = <Week 6 DBURL/>
  • run npm i to install the needed pacakges

Build The database

  • Chage the build.sql file so that it creates a user table that has email (unique) and password attributes
  • Run your db_build.js file
  • You should get this Everdything is Okay.

Build the needed queries

  • Write function in /src/database/queries/addUser that takes email and password and add them to the database (needed for signup handler)
  • Write function in /src/database/queries/getUser that takes email and then returns their password (needed to handle user login)

Write the handlers

if you go to the router.js file you will see that we are missing two handler:

  • signup post that should handle the request that adds a user to the database, if the email already exists it should respond accordingly.

  • login in that should handle login request, if the login details are correct then user should be logged by checking adding cookies and then redirect to the cities page.

Secure Authenticated endpoints

Two endpoint should be secured, the server shouldn't add/return data in the following endpoint if the user is not logged in

  • Add a city POST /addcity
  • get cities GET /cities

I left comment in the router.js file.

Good Luck

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.