/parking-lot

Parking lot API ⛺

Primary LanguageTypeScriptMIT LicenseMIT

Parking lot

Build Status Coverage Status e2e

Assumption

  • Scenario: free parking lot without human intervention.
  • parking lot:
    • can create unlimited parking lots.
    • can set the number of slots in each parking lot.
  • car
    • the car must park at the same slot size only.
  • size:
    • slots sizes: small, medium, large.
    • car sizes: small, medium, large.
  • pricing: free.

Running the API

Development

  • Install Node.js 15.12.0
  • Update the environment variables in .env file (you can see the example in .env.example)
  • Run npm install
  • Run npm run start:dev

Production

Test Scripts

Tests are written using Jest and can be run using

# unit tests
$ npm run test

# e2e tests
$ npm run test:e2e

# test coverage
$ npm run test:cov

for production you have to run docker exec -it parkinglot_api sh before running test scripts

Document APIs

MongoDB Databases

 - parkingLots
        - _id
        - rank
        - name
        - slots
          - smalls
            - slotId
            - isAvailable
          - mediums
            - slotId
            - isAvailable
          - larges
            - slotId
            - isAvailable
        - createdAt
 - tickets
        - _id
        - parkingLotId
        - slotId
        - plateNumber
        - carSize
        - exitAt
        - createdAt

API Endpoints

  • POST /parkinglot to create parking lot

  • POST /car/park to park a car in a parking lot

  • POST /car/exit to check out a parking

  • GET /car/status to get available slots of all parking slots

  • GET /ticket?vehicleSize=large to get ticket

TODOs

  • E2E test
  • Unit test
  • JWT for Authentication
  • Example for client use
  • Dockerfile for development

Reference