A booking API developed in Ruby on Rails and authenticated with a JWT-based system using the devise-jwt
gem.
Documentation is still WIP.
Install gems:
bundle install
Set up your database:
rails db:create
rails db:migrate
Seed your database (Optional - includes dummy user for authentication login, as well as customers, appointments, and Japanese national holidays):
rails db:seed
Testing (for documentation mode add the -fd
flag to the end):
rspec
In your terminal:
rails server
POST
/signup
Registers a new user with the credentials provided in the parameters. These credentials can be used to sign in and access authorization-protected routes. A JWT Bearer token is returned in the response's authorization
header.
name type data type description required string User email password required string User password
http code content-type response 201
text/plain;charset=UTF-8
Signed up successfully
400
application/json
{"code":"400","message":"User couldn't be created successfully. <current_user.errors.full_messages>"}
curl --location 'http://localhost:3001/signup' \ -H 'Content-Type: application/json' \ --data-raw '{ "user": { "email": "test@test.com", "password": "test1234" } }'
POST
/login
Sign a user in using existing credentials. Returns a JWT Bearer token in the response's authorization
header that can be used in protected routes' request headers.
name type data type description required string User email password required string User password
http code content-type response 200
text/plain;charset=UTF-8
Logged in successfully.
401
application/json
{"code":"401","message":"Invalid Email or password"}
curl --location 'http://localhost:3001/login' \ -H 'Content-Type: application/json' \ --data-raw '{ "user": { "email": "test@test.com", "password": "test1234" } }'
DELETE
/logout
Sign a user out of a session. Requires a valid JWT Bearer token in the request's authorization
header (received in response headers from either POST
/login
or POST
/signup
).
None
http code content-type response 200
text/plain;charset=UTF-8
Logged out successfully.
401
application/json
{"code":"401","message":"Not authorized to access that route."}
curl -L -X DELETE 'http://localhost:3001/logout' \ -H 'Authorization: Bearer <auth_token>'