This project is focused on how to authenticate a Ruby-on-Rails API only app using
gem devise,gem devise-jtwandJWT Tokens
- Ruby 3.1.2
- Rails 7.0.4
- PostgreSQL
To get a working local copy, follow these steps listed bellow.
In order to run this project you need:
- Nodejs installed on your computer
- Visual studio code or your preferred code editor
- Have a basic Knowledge i Ruby-on-Rails and APIs
Open your terminal inside your destination folder and run the command bellow to clone this repository to your folder:
git clone git@github.com:Chrissiku/rails-api-authentication-crud.gitor just
git clone https://github.com/Chrissiku/rails-api-authentication-crudThen :
cd rails-api-authentication-crud/Install all gems
bundle installCreate database
rails db:createRun migrations to create all tables
rails db:migratesee the database
rails db:seedRun the project on your local server
rails serverNow you can navigate to http://127.0.0.1:3000 inside Postman and enjoy all the end-points
To run the project, execute the following command:
Open Postman and perform the following tests;
Examples
-
Register a new user Request :
POSTURL :http://127.0.0.1:3000/usersBody :{ "user" : { "email":"user@gmail.com", "password":"123456" } }
-
Login a new user Request :
POSTURL :http://127.0.0.1:3000/users/sign_inBody :{ "user" : { "email":"user@gmail.com", "password":"123456" } }
-
Logout a new user Request :
DELETEURL :http://127.0.0.1:3000/users/sign_outHeader :Copy header form the login -
Logged User
Request :
GETURL :http://127.0.0.1:3000/users/current -
Get ALl users
Request :
GETURL :http://127.0.0.1:3000/users/allHeader : `Copy header form the login -
List all companies
Request :
GETURL :http://127.0.0.1:3000/api/v1/companies/Header : -
Create a new company Request :
POSTURL :http://127.0.0.1:3000/api/v1/companies/Body :{ "company": { "name": "company 1", "address": "address", "established_year": "2022" } }
-
Update company Request :
PATCHorPUTURL :http://127.0.0.1:3000/api/v1/companies/:idBody :{ "company": { "name": "company updated", "address": "address", "established_year": "2022" } }
-
Delete a company Request :
DELETEURL :http://127.0.0.1:3000/api/v1/companies/:id
👤 Chris Siku
- GitHub: @Chrissiku
- LinkedIn: [christian-siku](https://www.linkedin.com/in/ christian-siku/)
- Create an appropriate frontend usinf NextJs, TypeScript and Reactjs
Contributions, issues, and feature requests are welcome!
Feel free to check the issues page.
Write a message to encourage readers to support your project
If you like this project...
To APPSIMPACT
This project is MIT licensed.