Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[M1-TR-210] Backend for M1_TR-4 #10

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

jasonchuasun
Copy link
Contributor

@jasonchuasun jasonchuasun commented Sep 4, 2023

Related Issue

Context

  • create schema, models, and migrations
  • create functions (services and controllers) for the following features:
    • customer registration
    • job detail creation, and
    • schedules creation
  • BE data validation and error handling should be applied
  • create unit tests for the services and controllers
  • setup swagger/nestjs - visit localhost:4000/api to test the functionalities

Commands:

  • startup docker
    docker-compose up -d

  • double check .env file if the DATABASE_URL is correct
    DATABASE_URL="postgresql://postgres:postgres@db:5432/jms?schema=public"

  • run prisma generate
    docker-compose exec server sh -c 'yarn run prisma generate'

  • run prisma migration
    docker-compose exec server sh -c 'yarn run prisma migrate dev'

  • run user seeders - seed 5 users in db. This is a needed step for the job service.
    Reason: userId prop is manually inputted to be user: 1.
    docker-compose exec server sh -c 'yarn run seed:users'

  • test out the functions using the swagger url - localhost:4000/api or in Postman using the ff endpoints:


API Endpoints

User

  • create - POST - localhost:4000/api/user/
  • findAll - GET - http://localhost:4000/api/user

Customer

  • create - POST - http://localhost:4000/api/customer
  • findAll - GET - http://localhost:4000/api/customer
  • findOne - GET - http://localhost:4000/api/customer/<id>

Job

  • create - POST - http://localhost:4000/api/job
    { "firstName": "sample", "lastName": "sample", "email": "sample@gmail.com", "contact": "0123456", "address": "a", "schedules": [ { "startDate": "2023-01-01T01:00:00.000Z", "endDate": "2023-01-02T01:00:00.000Z", "startTime": "2000-01-01T01:00:00.000Z", "endTime": "2000-01-01T02:00:00.000Z"}], "title": "a", "type": "a", "tags": "TAG_A", "remarks": "a", "paymentMethod": "CARD", "userId": 2 }
  • findAll - GET - http://localhost:4000/api/job
  • findOne - GET - http://localhost:4000/api/job/<id>

Schedules

  • create - POST - http://localhost:4000/api/schedule
  • findAll - GET - http://localhost:4000/api/schedule

Test Executed

  • Unit Tests for User, Customer, Job, and Schedule
    • yarn test

Notes

  • enums are set for the following:
    Role: "USER" | "ADMIN"
    Tag: "TAG_A" | "TAG_B" | "TAG_C"
    PaymentMethod: "CASH" | "CARD" | "BANK_TRANSER"
  • creating the a job that has the same customer details (email: unique) and Job Title will throw a BadRequestException
  • customer registration is included in the first portion of job registration - duplicate customer registration (duplicate emails) is skipped.

Screenshot

image
image
image

Nature of task

  • Feature

Risks

  • [ ]

@jasonchuasun jasonchuasun self-assigned this Sep 4, 2023
@jasonchuasun jasonchuasun force-pushed the feature/M1-TR-210 branch 3 times, most recently from af285ab to 8e4b1c9 Compare September 4, 2023 08:42
@jasonchuasun jasonchuasun force-pushed the feature/M1-TR-210 branch 4 times, most recently from bdeb55e to ecb8f1d Compare September 7, 2023 14:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants