Giter Club home page Giter Club logo

backend-md-template's Introduction

Markdown Backend Template

Table of Contents

API Documentation

Dummy Data

Test users with projects

Users: [
  {
    "id": 1,
    "username": "admin",
    "password": "password"
    "name": "Leonel, Gabriel, and Mateo",
    "about": "We are a team of drone hobbyists.",
    "projects": [
      {
        "id": 1,
        "projectName": "Drone Fanatics",
        "projectType": "Robotics",
        "description": "We would like to expand our photography drone creation and repair hobby into a business.",
        "fundingAmount": 5000.00,
        "user_id": 1,
      }
    ]
  },
  {
    "id": 2,
    "username": "admin2",
    "password": "password",
    "name": "Jayla",
    "about": "I created a small 3D printing business.",
    "projects": [
      {
        "id": 2,
        "projectName": "Jayla's Trinkets",
        "projectType": "3D Printing",
        "description": "I currently run my business with one 3D printer. I would like to expand to four printers so I can increase my productivity and sales.",
        "fundingAmount": 15000.00,
        "user_id": 2,
      },
    ]
  },
  {
    "id": 3,
    "username": "admin3",
    "password": "password",
    "name": "Aaliyah and Trinity",
    "about": "We are working to create drought resistance crops.",
    "projects": [
      {
        "id": 3,
        "projectName": "Genexis Lab",
        "projectType": "Biotechnology",
        "description": "We currently have a small lab where we are working on creating drought resistant crops. We are in need of some new equipment and supplies.",
        "fundingAmount": 10000.00,
        "user_id": 3,
      },
    ]
  }
]

Auth Routes

Table Method Endpoint Description
users POST /auth/register Registers a new user.
users POST /auth/login Logs in already registered user.

Register

Registers a new user.

Method URL: /auth/register

HTTP Method: [POST]

Request Body

Name Type Required Description
username String Yes Must be unique.
password String Yes
email String No

Examples

{
  "username": "superchef",
  "password": "ilovefood",
  "email": "[email protected]"
}

Response

201 (Created)

If you successfully register a user, the endpoint will return an HTTP response with a status code 201.

400 (Bad Request)

If you are missing a username or password, the endpoint will return an HTTP response with a status code of 400.

500 (Internal Service Error)

If there is a server or database error, the endpoint will return an HTTP response with a status code of 500.

Login

Logs in an already registered user.

Method URL: /auth/login

HTTP Method: [POST]

Request Body

Name Type Description
username String Must match username in database.
password String Must match password to corresponding username in database.

Example

{
  "username": "vrproject",
  "password": "ilovemoney"
}

Response

{ "name": "John", "about": "Tech developer" }

200 (OK)

If you successfully log in, the endpoint will return an HTTP response with a status code 200.

400 (Bad Request)

If you are missing a username or a password, the endpoint will return an HTTP response with a status code of 400.

401 (Unauthorized)

If you provide invalid credentials, the endpoint will return an HTTP response with a status code of 401.

500 (Internal Service Error)

If there is a server or database error, the endpoint will return an HTTP response with a status code of 500.

User Routes

Get Users

Gets a list of users.

Method URL: /users/

HTTP Method: [GET]

Headers

Name Type Required Description
Content-Type String Yes Must be application/JSON
Authorization String Yes JSON Web Token

Response

200 (OK)

If users are found, the endpoint will return an HTTP response with a status code 200.

404 (Not Found)

If users are not found, the endpoint will return an HTTP response with a status code 404.

401 (Unauthorized)

If user does not have access, the endpoint will return an HTTP response with a status code of 401.

500 (Internal Service Error)

If there is a server or database error, the endpoint will return an HTTP response with a status code of 500.

Get User

Gets user by ID.

Method URL: /users/:id

HTTP Method: [GET]

Return

Response

200 (OK)

If user with specified ID is found, the endpoint will return an HTTP response with a status code 200.

404 (Not Found)

If user with specified ID is not found, the endpoint will return an HTTP response with a status code 404.

401 (Unauthorized)

If user does not have access, the endpoint will return an HTTP response with a status code of 401.

500 (Internal Service Error)

If there is a server or database error, the endpoint will return an HTTP response with a status code of 500.

Get Projects by User ID

Gets all projects for specified user.

Method URL: /users/:id/projects

HTTP Method: [GET]

Headers

Name Type Required Description
Content-Type String Yes Must be application/JSON
Authorization String Yes JSON Web Token

Response

200 (OK)

If user with specified ID is found, the endpoint will return an HTTP response with a status code 200.

404 (Not Found)

If user with specified ID is not found, the endpoint will return an HTTP response with a status code 404.

401 (Unauthorized)

If user does not have access, the endpoint will return an HTTP response with a status code of 401.

500 (Internal Service Error)

If there is a server or database error, the endpoint will return an HTTP response with a status code of 500.

Delete User

Deletes user by ID.

Method URL: /users/:id

HTTP Method: [DELETE]

Headers

Name Type Required Description
Content-Type String Yes Must be application/JSON
Authorization String Yes JSON Web Token

Response

200 (OK)

If user with specified ID is found and deleted, the endpoint will return an HTTP response with a status code 200.

404 (Not Found)

If user with specified ID is not found, the endpoint will return an HTTP response with a status code 404.

401 (Unauthorized)

If user does not have access, the endpoint will return an HTTP response with a status code of 401.

500 (Internal Service Error)

If there is a server or database error, the endpoint will return an HTTP response with a status code of 500.

Update User

Updates user by ID.

Method URL: /users/:id

HTTP Method: [PUT]

Headers

Name Type Required Description
Content-Type String Yes Must be application/JSON
Authorization String Yes JSON Web Token

Body

Name Type Required Description
username String Yes Must be unique.
password String Yes
name String Yes
about Text Yes

Example

{
  "username": "vrproject",
  "password": "ilovemoney",
  "name": "John",
  "about": "Tech developer"
}

Response

200 (OK)

If user with specified ID is found and updated, the endpoint will return an HTTP response with a status code 200.

404 (Not Found)

If user with specified ID is not found, the endpoint will return an HTTP response with a status code 404.

401 (Unauthorized)

If user does not have access, the endpoint will return an HTTP response with a status code of 401.

500 (Internal Service Error)

If there is a server or database error, the endpoint will return an HTTP response with a status code of 500.

Project Routes

Create Project

Creates a project, with a project type, description, funding amount, and user id.

Method URL: /projects

HTTP Method: [POST]

Headers

Name Type Required Description
Content-Type String Yes Must be application/JSON
Authorization String Yes JSON Web Token

Body

Name Type Required Description
projectName String Yes
projectType String Yes
description String Yes
fundingAmount Decimal Yes
user_id Integer Yes

Example

{
  "projectName": "Test project 1",
  "projectType": "Tech",
  "description": "Small tech business test project 1",
  "fundingAmount": 5000.00,
  "user_id": 1,
}

Response

201 (Created)

If project is created, the endpoint will return an HTTP response with a status code 201.

400 (Bad Request)

If you are missing any project information, the endpoint will return an HTTP response with a status code of 400.

401 (Unauthorized)

If user does not have access, the endpoint will return an HTTP response with a status code of 401.

500 (Internal Service Error)

If there is a server or database error, the endpoint will return an HTTP response with a status code of 500.

Get Projects

Gets a list of projects.

Method URL: /projects

HTTP Method: [GET]

Headers

No headers needed. /projects is not a protected path.

Response

200 (OK)

If projects are found, the endpoint will return an HTTP response with a status code 200.

404 (Not Found)

If projects are not found, the endpoint will return an HTTP response with a status code 404.

500 (Internal Service Error)

If there is a server or database error, the endpoint will return an HTTP response with a status code of 500.

Get Projects

Gets project by ID.

Method URL: /projects/:id

HTTP Method: [GET]

Headers

No headers needed. /projects/:id is not a protected path.

Response

200 (OK)

If project with specified ID is found, the endpoint will return an HTTP response with a status code 200.

404 (Not Found)

If project with specified ID is not found, the endpoint will return an HTTP response with a status code 404.

500 (Internal Service Error)

If there is a server or database error, the endpoint will return an HTTP response with a status code of 500.

Update Project

Updates project by ID.

Method URL: /projects/:id

HTTP Method: [PUT]

Headers

Name Type Required Description
Content-Type String Yes Must be application/JSON
Authorization String Yes JSON Web Token

Body

Name Type Required Description
projectName String Yes
projectType String Yes
description String Yes
fundingAmount Decimal Yes
user_id Integer Yes

Example

{
  "projectName": "Test project 1",
  "projectType": "Tech",
  "description": "Small tech business test project 1",
  "fundingAmount": 5000.00,
  "user_id": 1,
}

Response

200 (OK)

If project with specified ID is found and updated, the endpoint will return an HTTP response with a status code 200.

404 (Not Found)

If project with specified ID is not found and updated, the endpoint will return an HTTP response with a status code 404.

401 (Unauthorized)

If user does not have access, the endpoint will return an HTTP response with a status code of 401.

500 (Internal Service Error)

If there is a server or database error, the endpoint will return an HTTP response with a status code of 500.

Delete Project

Deletes project by ID.

Method URL: /projects/:id

HTTP Method: [DELETE]

Headers

Name Type Required Description
Content-Type String Yes Must be application/JSON
Authorization String Yes JSON Web Token

Response

200 (OK)

If project with specified ID is found and deleted, the endpoint will return an HTTP response with a status code 200.

404 (Not Found)

If project with specified ID is not found and deleted, the endpoint will return an HTTP response with a status code 404.

401 (Unauthorized)

If user does not have access, the endpoint will return an HTTP response with a status code of 401.

500 (Internal Service Error)

If there is a server or database error, the endpoint will return an HTTP response with a status code of 500.

backend-md-template's People

Contributors

elijahdaniel avatar

Watchers

James Cloos avatar  avatar

Forkers

robertmisch

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.