Coding Exercise for NestJs Backend Developer
Explore the docs »
A simple NestJS REST application that schedules a sports slot with authenticated requests.
To get a local copy up and running follow these simple steps.
This is an example of how to list things you need to use the software and how to install them.
- npm
npm install npm@latest -g
- yarn
npm install -g yarn
- Clone the repo
git clone https://github.com/sanjaybaskaran/sports-scheduler.git
- Configure .env
MYSQL_DATABASE = "flowace"
MYSQL_ROOT_PASSWORD = "1234"
DATABASE_URL = "mysql://root:1234@localhost:3306/flowace"
SESSION_SECRET = "PNb)G9U[0gu^CMe#[i'6Ib9<?|@Gnf"
- Building Docker Containers
docker-compose up -d --build
- Create Database Schema
yarn migrate
GET
/api/user
GET
/api/sport_schedule
POST
/api/sport_schedule/create
GET
api/user
(Lists all the users)
name type data type description None
http code content-type response 200
application/json
{[<Array of User Data>]}
403
application/json
{"statusCode": 403,"message": "Forbidden resource","error": "Forbidden"}
POST
/api/user/create
(Inserts a new User into database)
name type data type description full_name required string Full name of the user required string email of the user password required string password of the user
http code content-type response 200
application/json
{"id":"$user_id","full_name":"$user_fullName","email":"$user_email"}
400
application/json
{"statusCode": 400,"message": "User with that email already exists"}
500
application/json
{"status":500,"message":"Internal server error"}
POST
/api/user/login
(Creates user session and logs the user in)
name type data type description required
string
email id of the user
password
required
string
password of the user
http code content-type response 200
application/json
{{ "status": "success", "message": "Logged in" }
401
application/json
{"statusCode": 401,"message": "Unauthorized"}
500
application/json
{"status":"failure","message":"Internal Server error"}
GET
/api/sport_schedule
(Lists all the sport schedule slots if authorized)
name type data type description None
http code content-type response 200
application/json
{[<Array of slot data>]}
403
application/json
{"statusCode": 403,"message": "Forbidden resource","error": "Forbidden"}
500
application/json
{"status":"failure","message":"Internal server error"
POST
/api/sport_schedule/create
(Inserts a new sport_schedule slot into database if authorized)
name type data type description name
required
string
Name of the sport
start_time
required
string
Start time in the 24 hour format of "HH-mm"
end_time
required
string
End time in the 24 hour format of "HH-mm"
date
required
string
Date in the format of "10 July 2022"
http code content-type response 200
application/json
{<Inserted slot data>}
400
application/json
{"statusCode":"400","message":<validation error message>}
403
application/json
{"statusCode": 403,"message": "Forbidden resource","error": "Forbidden"}
500
application/json
{"status":"failure","message":"Internal Server Error"}
Hey everybody! My name is Sanjay Kumar Baskaran, I'm extremely grateful to have this opportunity to apply for this position. I learnt a lot while building this project 😀
Sanjay Baskaran |