/sport_scheduler

NestJS + Prisma + MySQL

Primary LanguageTypeScript


Sports-Scheduler

Coding Exercise for NestJs Backend Developer
Explore the docs »

Table of Contents

About The Project

A simple NestJS REST application that schedules a sports slot with authenticated requests.

Built With

Getting Started

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

Prerequisites

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

Installation

  1. Clone the repo
git clone https://github.com/sanjaybaskaran/sports-scheduler.git
  1. 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"
  1. Building Docker Containers
docker-compose up -d --build
  1. Create Database Schema
yarn migrate

Usage

Protected Routes

GET /api/user
GET /api/sport_schedule
POST /api/sport_schedule/create

For Users


GET api/user (Lists all the users)

Parameters
name type data type description
None
Responses
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)

Parameters
name type data type description
full_name required string Full name of the user
email required string email of the user
password required string password of the user
Responses
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)

Parameters
name type data type description
email required string email id of the user
password required string password of the user
Responses
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"}

For Sport_Schedule


GET /api/sport_schedule (Lists all the sport schedule slots if authorized)

Parameters
name type data type description
None
Responses
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)

Parameters
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"
Responses
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"}

Meet the Developer

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