An open API service indexing awesome lists of open source software.

https://github.com/teekaytech/virtual-technical-help-app-backend

This is the server side of a technical support application. This app is built to connect micronauts (microverse students) who may need technical help to Technical Support Engineers, using Microverse (an online training school for remote software developers) as a case study.
https://github.com/teekaytech/virtual-technical-help-app-backend

jwt-token rails7

Last synced: 3 months ago
JSON representation

This is the server side of a technical support application. This app is built to connect micronauts (microverse students) who may need technical help to Technical Support Engineers, using Microverse (an online training school for remote software developers) as a case study.

Awesome Lists containing this project

README

          

# Virtual Technical Help Application (Backend)

> This is the Server side of a technical support application. This app is built to connect micronauts (microverse students) who may need technical help to Technical Support Engineers, using microverse (an online training school for remote software developers) as a case study. The client-side implementation can be found [here](https://github.com/teekaytech/Virtual-Technical-Help-App-Frontend.git)

## Built With

- Ruby v2.7.1
- Ruby on Rails 7.0.2.1
- Rspec
- JWT
- Heroku

## Core Functionalities

- **User authentication:** allows new user to register and existing users to login.
- **Fetch all Engineers:** enables users to view available engineers and their individual details.
- **Fetch all Appointments:** enables users to view existing appointments, both past and future.
- **Create new appointment:** allows users to book a new appointment.

## Getting Started

To get a local copy up and running follow these simple example steps.

- On the project GitHub page, navigate to the main page of the repository [this page](https://github.com/teekaytech/Virtual-Technical-Help-App-Frontend.git).
- Under the repository name, locate and click on a green button named `Code`.
- Copy the project URL as displayed.
- If you're running Windows Operating System, open your command prompt. On Linux, Open your terminal.
- Change the current working directory to the location where you want the cloned directory to be made. Leave as it is if the current location is where you want the project to be.
- Type `git clone`, and then paste the URL you copied in Step 3.

`$ git clone https://github.com/teekaytech/Virtual-Technical-Help-App-Frontend.git` Press Enter key

- Press Enter. Your local copy will be created.

## Prerequisites

- [Git](https://gist.github.com/derhuerst/1b15ff4652a867391f03).
- Web browser (Chrome/Firefox)
- [Node](https://nodejs.org/en/)
- [NPM](https://www.npmjs.com/get-npm)
- Ruby v2.7.1
- Ruby on Rails v7
- Postgresql v >= 9.5

## Project Setup

_After cloning, the following steps setup the project_

- `cd technical-help-backend` to change the current working directory.
- `git checkout development` to access the most recent files and features.
- `bundle install` to install all necessary dependencies.
- `rails db:create` && `rails db:migrate` to create database and tables.
- `rails db:seed` to populate database with Dummie data.
- `touch .env` to create an env file. This requires two(2) keys namely: `JWT_TOKEN` & `SECRET_KEY_BASE`. `JWT_TOKEN` can be set to whatever you desire, while `SECRET_KEY_BASE` value can be generated with: `rake secret`.
```
JWT_TOKEN=<>
SECRET_KEY_BASE=<>
```
- `rails s` to start the application. You're all set.
Feel free to use POSTMAN or any other similar infrastructure to test the different endpoints.

To run test suites included, run:

- `bundle exec rspec`

## API Documentation

> The base URL for all endpoints is `https://boiling-basin-10755.herokuapp.com/api/v1/`. Some requests requires validation while some does not. The validation is implemented using tokens generated by JWT upon registration or login. This token is then sent with the headers of the requests that requires validation, so that it can be decoded and the app can determine if the token is valid or not. If valid, the user can successfully access such end-points that requires authentication.

**Summary of Available API Endpoints**
| Endpoint | Feature | Authentication |
| ------------ | ------------| ---------- |
| POST /users | Registers a new user | False |
| POST /login | Logs in a user | False |
| GET /auto_login | Checks login status of the current user | True |
| POST /appointments | Creates a new appointment | True |
| GET /appointments | Fetches all available appointment for logged user | True |
| GET /engineers | Fetches all available engineers | False |
| GET /engineers/:id | Fetches the details of a specific engineer | False |
| DELETE /logout | Logs out a user | False |

**Sampling a request that requires authentication**

_Fetch Appointments: endpoint fetches all the appointments already booked by the logged in user. Therefore, it requires authorization._

Endpoint: `https://boiling-basin-10755.herokuapp.com/api/v1/appointments`

Request (from POSTMAN):

```js
token = 'eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoxfQ.JC6qKuH9SG0SIiYSfhZUFTtirxN9Q47buLk0DPFFFzE'
curl --location --request GET 'https://boiling-basin-10755.herokuapp.com/api/v1/appointments' \
--header 'Authorization: Bearer ' \
```

Response:

```json
[
{
"date_created": "2020-12-08T11:14:06.414Z",
"id": 6,
"date": "2020-12-09T13:15:00.000Z",
"status": "Upcoming",
"duration": "90",
"engineer": "Boris Simonis",
"location": "Cyprus"
}
]
```

**Sampling a request that DOES NOT require authentication**

_Login: endpoint fetches creates a new token and ensure that the user can access all features._

Endpoint: `https://boiling-basin-10755.herokuapp.com/api/v1/login`

Request (From POSTMAN):

```js
curl --location --request POST 'https://boiling-basin-10755.herokuapp.com/api/v1/login' \
--form 'username="johndoe"' \
--form 'password="password"'
```

Response:

```json
{
"user": {
"id": 1,
"name": "John Doe",
"username": "johndoe",
"email": "john@doe.com"
},
"token": "eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoxfQ.JC6qKuH9SG0SIiYSfhZUFTtirxN9Q47buLk0DPFFFzE",
"logged_in": true
}
```

## Deployment

This app was deployed to Heroku and is accessible at: `https://boiling-basin-10755.herokuapp.com`

## Author

👤 **Taofeek Olalere**

- Github: [@teekaytech](https://github.com/teekaytech)
- Twitter: [@ola_lere](https://twitter.com/ola_lere)
- Linkedin: [olaleretaofeek](https://linkedin.com/in/olaleretaofeek)
- Portfolio: [Olalere Taofeek](https://teekaytech.github.io/olaleretaofeek/)

## 🤝 Contributing

Contributions, issues and feature requests are welcome!

Feel free to check the [issues page](https://github.com/teekaytech/React-Calclator/issues/).

## Show your support

Give a ⭐️ if you like this project!

## Acknowledgments

- [Microverse](https://.microverse.org/)
- [Reinald Reynoso's articles medium](https://medium.com/better-programming/build-a-rails-api-with-jwt-61fb8a52d833)
- [Images stored with Cloudinary](https://cloudinary.com/)

## 📝 License

This project is [MIT](/LICENSE) licensed.