Code Monkey home page Code Monkey logo

backend's Introduction

Backend


Deployed Backend: https://build-week-how-to.herokuapp.com/

How-Tos is a full-stack web application that was built during a "build week" by Lambda School students. Each student fulfills a role in the project to collectively build the application.

How-Tos gives users a site where they can add and edit their own how-tos and everyone else who is signed up can see.

Using


  • Node.js - JavaScript runtime for executing JavaScript at the server outside the browser
  • Express.js - Lightweight web framework to bootstrap Node.js APIs
  • SQLite - Super lightweight database to bootstrap development environments
  • PostgreSQL - An advanced object-relational database for production environments
  • Knex.js - A SQL query builder that helps abstracting migrations and DDLs for different database types into a single coherent structure
  • Knex-Cleaner - Helper library to clean a PostgreSQL, MySQL or SQLite3 database tables using Knex
  • Bcrypt.js - A module to help make passwords more secure
  • CORS - A Node.js package for providing a Connect/Express middleware that can be used to enable CORS with various options
  • Helmet - A collection of 14 smaller middleware functions that set HTTP response headers
  • JWT - JSON Web Token for authorization and client side tokens for security
  • Supertest - A test module for HTTP assertions
  • Jest - A simple JavaScript testing framework
  • Dotenv - a zero-dependency module that loads environment variables from a .env file into process.env

BASEURL

ENDPOINTS

Endpoint Request Type Request Response
/api/auth/register POST {username: "", password: "", email: "", usertype: int} {welcome: username, password: encrypted string}
/api/auth/login POST {username: "", password: ""} {userobject, token}

Examples:

/api/auth/register
POST
  • JWT protected (header) ❌

  • payload (body) ✔️

    {
      username: "dannybb";
      password: "nestor12!";
      email: "[email protected]";
      usertype: "Content Creator";
    }

    /api/auth/login POST

  • JWT protected (header) ❌

  • payload (body) ✔️

    {
      username: "dannybb";
      password: "nestor12!";
    }

ENDPOINTS

Endpoint Request Type Request Response
/api/howtos GET requires a token [{howtos}]
/api/howtos/:id GET requires a token {instruction: string, number: int}
/api/howtos POST {name: "", desc: "", user_id: int} no return at the moment
/api/howtos/:id PUT {name: "", desc: "", user_id: int} no return at the moment
/api/howtos/:id DELETE {} no return at the moment

Examples:

/api/howtos GET

  • JWT protected (header) ✔️

  • payload (body) ❌

    {
      Headers{ Authorization: token};
    }

    /api/howtos/:id GET

  • JWT protected (header) ✔️

  • payload (body) ❌

    {
      Headers{ Authorization: token};
    }

    /api/howtos POST

  • JWT protected (header) ✔️

  • payload (body) ✔️

    {
      name: "howto howto"
      desc: "this will show you howto howto"
      user_id: 3
      Headers{ Authorization: token};
    }

    /api/howtos/:id PUT

  • JWT protected (header) ✔️

  • payload (body) ✔️

    {
      name: "howto howto"
      desc: "this will show you howto howto"
      user_id: 3
      Headers{ Authorization: token};
    }

    /api/howtos/:id DELETE

  • JWT protected (header) ✔️

  • payload (body) ❌

    {
      Headers{ Authorization: token};
    }

ENDPOINTS

Endpoint Request Type Request Response
/api/howtos/:id/steps GET requires a token [{number: int}, {intruction: string}]
/api/howtos/:id/steps/:number GET requires a token {instruction: string}
/api/howtos/:id/steps POST {number: int, instruction: string} no return at the moment
/api/howtos/:id/steps/:number PUT {number: int, instruction: string} no return at the moment
/api/howtos/:id/steps/:number DELETE {} no return at the moment

Examples:

/api/howtos/:id/steps GET

  • JWT protected (header) ✔️

  • payload (body) ❌

    {
      Headers{ Authorization: token};
    }

    /api/howtos/:id/steps/number GET

  • JWT protected (header) ✔️

  • payload (body) ❌

    {
      Headers{ Authorization: token};
    }

    /api/howtos/:id/steps POST

  • JWT protected (header) ✔️

  • payload (body) ✔️

    {
      number: 1
      instruction: "read this document"
      user_id: 3
      Headers{ Authorization: token};
    }

    /api/howtos/:id/steps/:number PUT

  • JWT protected (header) ✔️

  • payload (body) ✔️

    {
      name: 1
      desc: "read the readme available at: "
      user_id: 3
      Headers{ Authorization: token};
    }

    /api/howtos/:id/steps/:number DELETE

  • JWT protected (header) ✔️

  • payload (body) ❌

    {
      Headers{ Authorization: token};
    }

ENDPOINTS

Endpoint Request Type Request Response
/api/howotos/:id/likes GET requires a token returns likes for a howto
/api/howotos/:id/likes/users GET requires a token returns all a users likes
/api/howotos/likes GET requires a token returns all likes
/api/howotos/:id/likes POST {user_id, howto_id} no return at the moment
/api/howotos/:id/likes DELETE {user_id, howto_id} no return at the moment

Examples:

/api/howtos/:id/likes GET

  • JWT protected (header) ✔️

  • payload (body) ❌

    {
      Headers{ Authorization: token};
    }

    /api/howtos/:id/likes/users GET

  • JWT protected (header) ✔️

  • payload (body) ❌

    {
      Headers{ Authorization: token};
    }

    /api/howtos/likes GET

  • JWT protected (header) ✔️

  • payload (body) ❌

    {
      Headers{ Authorization: token};
    }

    /api/howtos/:id/likes POST

  • JWT protected (header) ✔️

  • payload (body) ✔️

    {
      howto_id: 1
      user_id: 3
      Headers{ Authorization: token};
    }

    /api/howtos/:id/likes PUT

  • JWT protected (header) ✔️

  • payload (body) ✔️

    {
      howto_id: 1
      user_id: 3
      Headers{ Authorization: token};
    }

    /api/howtos/:id/steps/:number DELETE

  • JWT protected (header) ✔️

  • payload (body) ❌

    {
      Headers{ Authorization: token};
    }

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.