Code Monkey home page Code Monkey logo

hpup-backend's Introduction

HpUp-Backend

Database

All Migration and Models generate by sequelize-cli

Mirgation

to create a database

npx sequelize-cli db:migrate\

to rollback all migration (clean database)

npx sequelize-cli db:migrate:undo:all\

Run seeds

npx sequelize-cli db:seed --seed 20210124111220-usertype
npx sequelize-cli db:seed --seed 20210124111153-user\

Inspiration and docs

[https://stackoverflow.com/questions/46357533/how-to-add-delete-new-columns-in-sequelize-cli]
[https://github.com/danielfsousa/express-rest-boilerplate]
[https://github.com/binitghetiya/express-sequelize-api-boilerplate]
[https://github.com/joshuaalpuerto/node-ddd-boilerplate]\

Migrations and models

(sequelize comand line manual)[https://www.npmjs.com/package/sequelize-cli] [https://dev.to/anayooleru/modifying-an-existing-sequelize-migration-1mnn]
[https://medium.com/@andrewoons/how-to-define-sequelize-associations-using-migrations-de4333bf75a7]
[https://medium.com/@eth3rnit3/sequelize-relationships-ultimate-guide-f26801a75554]\

sequelize docs [https://sequelize.org/v3/]

Available endpoints

_ Auth _

Sign up
POST http://188.166.50.249/signup

{
"username": "test",
"email": "[email protected]",
"password": "123123",
"imgUrl":"",
"basedCountry":"USA",
"about":"",
"remainingDays":123,
"role":"employer",
"requests":"",
"companyId":1
}

Login
POST http://188.166.50.249/login

{
"username": "test",
"password": "123123"
}

LogOut
GET http://188.166.50.249/logout

_ User _

Get all users
GET http://188.166.50.249/users

Get User by id
GET http://188.166.50.249/users/(id)

Edit User
PATCH http://188.166.50.249/users/(id)

{
"username": "aga",
"email": "[email protected]",
"password": "123123",
"imgUrl":"",
"basedCountry":"USA",
"about":"",
"remainingDays":123,
"role":"employer",
"requests":"",
"companyId":1
}

Delete User
DELETE http://188.166.50.249/users/(id)

Get all request for User with ID
GET http://188.166.50.249/users/(id)/requests

_ Companies _

Get all Companies
GET http://188.166.50.249/companies

Get Company by id
GET http://188.166.50.249/companies/(id)

Add Company
POST http://188.166.50.249/companies

{
  "operatingCountries": [
    "Spain"
  ],
  "name": "Super Puper comp"
}

Edit Company
PATCH http://188.166.50.249/companies/(id)

{
  "operatingCountries": [
    "Spain",
		"USA"
  ],
  "name": "Super Puper comp LTD"
}

Delete Company
DELETE http://188.166.50.249/companies/(id)

Requests

Get all Requests
GET http://188.166.50.249/hollyday

Get Request by id
GET http://188.166.50.249/hollyday/(id)

Add Request
POST http://188.166.50.249/hollyday

{
"initDate":"2021-02-13 17:56:37",
"endDate":"2021-02-13 17:56:37",
"type":"holidays",
"status":"open",
"title":"Lorem Ipsum",
"description":"Lorem Ipsum is simply dummy text of the printing and typesetting industry.",
"documentUrl":"",
"userId":"1",
"companyId":"1"
}

Edit Request
PATCH http://188.166.50.249/hollyday/(id)

{
"initDate":"2021-02-13 17:50:37",
"endDate":"2021-02-13 17:56:37",
"type":"holidays",
"status":"approved",
"title":"Lorem Ipsum",
"description":"Lorem Ipsum is simply dummy text of the printing and typesetting industry.",
"documentUrl":"",
"userId":"1",
"companyId":"1"
}

Delete Request
DELETE http://188.166.50.249/hollyday/(id)

TODO

  1. validation request
  2. req.session.currentUser , use to return data just for this company
  3. req.session.currentUser , use to validate user rights according to user type
  4. add seeds for Request

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.