A RESTful API built with Express.js for a car rental business.
This project is a RESTful API built with Express.js for a car rental business. The API handles CRUD operations for cars, rentals, matches, notifications, payments, reviews, and users. It also includes websocket for chat system. The authentication and authorization middleware for protected routes. The API is used by the car rental website built with React.js.
To get started with this project, you need to:
- Clone this repository to your local machine
- Install dependencies by running the following command:
npm install
- Create a
.env
file based on the example provided in.env.example
file - Start the server with the following command:
npm start
Alternatively, if you want to run it in development mode, use: npm run dev
This API supports the following endpoints:
GET /car
: Get all cars, POST create a new car, PATCH update a car, DELETE a carGET /car/admin
: Get all cars for admin, filter and searchPOST /car/me/:username
: Get cars of the logged in lessorGET /car/:id
: Get a car by idGET /car/busy/:id
: Get unavailable times for a carGET /car/number-of-rental/:id
: Get number of rentals for a carPATCH /car/change-car-info
: Change car infoPATCH /car/status
: Toggle car statusPATCH /car/reserve
: Reserve a carPOST /chat
: Create a new chatPATCH /chat/noti
: Toggle chat notificationGET /match
: Get matches of the logged in user, POST create a new matchGET /match/status
: Get match statusesGET /match/admin
: Get matches for admin, filter and searchGET /match/:id
: Get match info by idGET /match/me/:id
: Get bookings of the logged in userPATCH /match/cancel-reservation
: Cancel a reservationPATCH /match/status
: Toggle match statusPATCH /match/complete
: Complete a matchPOST /notification
: Create a new notification, GET all notifications, PATCH read notificationsGET /notification/have-noti
: Check if user has unread notificationsGET /payment
: Get all payments, POST create a new paymentGET /payment/:id
: Get a payment by idPOST /payment/charge/:id
: Create an Omise chargePOST /payment/transfer/:id
: Create an Omise transferPOST /payment/transaction/:id
: Get Omise transactionsGET /review
: Get all reviews, POST create a new reviewGET /review/:id
: Get a review by idPOST /user
: Create a new userPATCH /user
: Update a user's rented countPOST /user/login
: Login a userGET /auth/google
: Authenticate user with GoogleGET /auth/google/callback
: Callback for Google authenticationPOST /user/role
: Get a user's rolePOST /user/info
: Get a user's info, PATCH update a user's infoPOST /user/logout
: Logout a userPOST /user/forgot-password
: Send reset link to user's emailPOST /user/reset-password
: Reset user's passwordGET /user/navbar
: Get navbar infoPATCH /user/update-role
: Update user's role as a lessorPATCH /user/lessor
: Change user's role to a lessorPATCH /user/togglereqLessor
: Toggle user's request to be a lessorPATCH /user/update-role-admin
: Update user's role as an adminPATCH /user/status
: Toggle user's statusGET /user/admin
: Get users for admin, filter and searchGET /api/user/chatRooms/:userId
: Get all chats for a userGET /csrf-token
: Get a CSRF token
Contributions are welcome! Feel free to open an issue or submit a pull request.
This project is licensed under the MIT License. See the LICENSE file for more details.