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
- Ruby v2.7.1
- Ruby on Rails 7.0.2.1
- Rspec
- JWT
- Heroku
- 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.
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.
- 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.
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, whileSECRET_KEY_BASE
value can be generated with:rake secret
.JWT_TOKEN=<<whatever>> SECRET_KEY_BASE=<<code generated from 'rake secret' command>>
-
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
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):
token = 'eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoxfQ.JC6qKuH9SG0SIiYSfhZUFTtirxN9Q47buLk0DPFFFzE'
curl --location --request GET 'https://boiling-basin-10755.herokuapp.com/api/v1/appointments' \
--header 'Authorization: Bearer <token>' \
Response:
[
{
"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):
curl --location --request POST 'https://boiling-basin-10755.herokuapp.com/api/v1/login' \
--form 'username="johndoe"' \
--form 'password="password"'
Response:
{
"user": {
"id": 1,
"name": "John Doe",
"username": "johndoe",
"email": "john@doe.com"
},
"token": "eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoxfQ.JC6qKuH9SG0SIiYSfhZUFTtirxN9Q47buLk0DPFFFzE",
"logged_in": true
}
This app was deployed to Heroku and is accessible at: https://boiling-basin-10755.herokuapp.com
👤 Taofeek Olalere
- Github: @teekaytech
- Twitter: @ola_lere
- Linkedin: olaleretaofeek
- Portfolio: Olalere Taofeek
Contributions, issues and feature requests are welcome!
Feel free to check the issues page.
Give a ⭐️ if you like this project!
This project is MIT licensed.