Skip to content

RocaManuel/viajando_api

Repository files navigation

Viajando API

Rest API to handle backend calls and some small business logic.

Auth

In order to make almost every call with this REST_API you need to generate a token using the "api/v1/users" GET method. In this token you will have some information that is ussefull (like user id) for future information handling.

The token is generated by a JWT using RS256 with a 4096 bit key.

Params

Every endpoint that requires any kind of param (query or body) will have a validator that will validate the name of each key that the endpoint needs and will validate also the type of information in that key, so make sure that you send the proper information or you will get a "Missing param or wrong type" error.

Endpoints

endpoints works using de versioning (actually we only have v1) and the prefix of controller sectioned for the zone that will affect. ex: for [Users] we would make host_route/api/v1/users

[users]

  • GET "/" - Requires a password and email to validate, returns basic (not sensitive) user data with an access_token. requires: - email: string - password: string
  • POST "/" - Used for registering users, requires: - city: string - location: string - name: string - lastname: string - email: string - password: string it also will create some other stuffs that the user will need in future like flags, timestamps, etc.
  • GET "/cars" - Requires every car for the token provided user (token that generates on login).

[Trips]

  • GET "/" - Requires all the trips that a user can access to (id on token).
  • GET "/by_id" Requires an specific trip by id - id: number
  • POST "/" - Create a Trip (owner) - driver_id: 'number' - car_id: 'number' - passenger_ammount: 'number' - from: 'string' - to: 'string' - city_name: 'string' - price: 'number' - start_on: 'string' - end_on: 'string' - is_periodic: 'boolean' - max_radio_killometer: 'number' - periodic_days: 'number'

[Cars]

  • GET "/" - Return a car with a provided id - id : number
  • POST "/" - Creates a new car in order to be added in futures trips. - driver_id: 'number' - car_size: 'number' - car_model: 'string' - car_age: 'string'

About

little rest api on express to handle messengers backend request

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published