Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/acushlakoncept/books-api-article-part3
https://github.com/acushlakoncept/books-api-article-part3
Last synced: 5 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/acushlakoncept/books-api-article-part3
- Owner: acushlakoncept
- Created: 2021-06-21T07:34:47.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2021-07-14T08:53:53.000Z (over 3 years ago)
- Last Synced: 2023-08-20T11:14:17.016Z (about 1 year ago)
- Language: Ruby
- Size: 54.7 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# How to Build a RESTful API Authentication With JWT (TDD Approach)
In this part of the project we we'll focus on the login, register endpoints, and securing our book's endpoint using JWT.
## Article
[How to Build a RESTful API Authentication With JWT (TDD Approach)](https://www.microverse.org/blog/build-a-restful-api-authentication-with-jwt)## Built With
- Ruby v2.7.2
- Ruby on Rails v6.0.3.2
- RSpec-Rails for testing## Current API Endpoints
The API will expose the following RESTful endpoints.
### BaseUrl: {Host-URL}/api/v1| Endpoint | Functionality |
|-------------------------|------------------------------|
| POST /register | Signup |
| POST /login | Login |
| GET /books | Get all books |
| GET /books/:id | Get a bppl |
| POST /books | Add a new book |
| DELETE /books/:id | Delete a book |
| PUT /books/:id | Update a book |
| POST /categories | Add category |
| GET /categories | Get categories |To get a local copy up and running follow these simple example steps.
### Prerequisites
Ruby: 2.6.5
Rails: 6.0.3.2
Postgres: >=9.5### Setup
~~~bash
$ git clone https://github.com/acushlakoncept/books-api-article-part3.git
$ cd books-api-article-part3
~~~Install gems with:
```
bundle install
```Setup database with:
> make sure you have postgress sql installed and running on your system
```
rails db:create
rails db:migrate
rails db:seed
```### Usage
Start server with:
```
rails server
```Open `http://localhost:3000/` in your browser.
### Deploy to a live server
Deploying to a live server like Heroku is easy, make sure you have the necessary credentials setup on your local machine
```bash
heroku create
heroku rename app-new-name
git push heroku $BRANCH_NAME:master
```
if you are already in master branch no need to add $BRANCH_NAME, just use `git push heroku master````bash
heroku run rails db:migrate
heroku run rails db:seed
heroku open
```Enjoy your newly deployed rails API
### Run tests
```
rpsec
```# Authors
👤 **Uduak Essien**
- Github: [@acushlakoncept](https://github.com/acushlakoncept/)
- Twitter: [@acushlakoncept](https://twitter.com/acushlakoncept)
- Linkedin: [acushlakoncept](https://www.linkedin.com/in/acushlakoncept/)## 🤝 Contributing
Contributions, issues and feature requests are welcome!
Feel free to check the [issues page](issues/).
## Show your support
Give a ⭐️ if you like this project!
## Acknowledgement
[Microverse Inc](https://www.microverse.org/)