This project is designed to manage user bookings, and authentication for a ride-sharing platform. It includes features for booking rides, handling driver and user registrations, and reviewing ride experiences.
These routes manage bookings, reviews, and ride statuses.
-
GET
/bookings/
- Description: Fetch all bookings or related data.
- Handler:
handleBooking
.
-
POST
/bookings/reviews
- Description: Submit a review (accessible by drivers and users).
- Middleware:
restrictTo(["driver", "user"])
. - Handler:
handleReviews
.
-
GET
/bookings/new
- Description: Get details for creating a new booking (for drivers only).
- Middleware:
restrictTo(["driver"])
. - Handler:
addNewBooking
.
-
POST
/bookings/
- Description: Create a new booking.
- Middleware:
restrictTo(["driver"])
,validateOrder
. - Handler:
handleNewBooking
.
-
GET
/bookings/myorders
- Description: Fetch all orders for the authenticated driver or user.
- Middleware:
restrictTo(["driver", "user"])
. - Handler:
handleMyOrders
.
-
POST
/bookings/cancelride
- Description: Cancel a ride (for users only).
- Middleware:
restrictTo(["user"])
. - Handlers:
cancelRide
,handleCancelRide
.
-
POST
/bookings/success
- Description: Mark a ride as completed (for drivers only).
- Middleware:
restrictTo(["driver"])
. - Handlers:
cancelRide
,handleCompleteRide
.
-
GET
/bookings/:id
- Description: Fetch booking details by ID (for users only).
- Middleware:
restrictTo("user")
. - Handler:
handleBookingDetails
.
These routes handle user registration, login, profiles, and ratings.
-
GET
/user/register
- Description: Display the registration page for users and drivers.
- Middleware:
denyAccessTo(["user", "driver"])
. - Handler: Renders
register.ejs
.
-
POST
/user/driver/successfull
- Description: Handles driver registration and signup.
- Middleware:
denyAccessTo(["user", "driver"])
. - Handler:
handleDriverSignUp
.
-
POST
/user/user/successfull
- Description: Handles user registration and signup.
- Middleware:
denyAccessTo(["user", "driver"])
. - Handler:
handleUserSignUp
.
-
GET
/user/register/driver
- Description: Displays the registration page specifically for drivers.
- Middleware:
denyAccessTo(["user", "driver"])
. - Handler: Renders
driverRegister.ejs
.
-
GET
/user/register/user
- Description: Displays the registration page specifically for users.
- Middleware:
denyAccessTo(["user", "driver"])
. - Handler: Renders
userRegister.ejs
.
-
GET
/user/login
- Description: Displays the login page.
- Handler: Renders
login.ejs
.
-
GET
/user/logOut
- Description: Logs out the current user, clears the session cookie, and redirects to the homepage.
- Handler: Clears
uid
cookie, flashes a success message, and redirects.
-
GET
/user/profile
- Description: Displays the profile page of the authenticated user.
- Middleware:
restrictTo(["driver", "user"])
. - Handler: Renders
profile.ejs
with the current user.
-
POST
/user/rating/:id
- Description: Allows a user to rate another entity (e.g., driver) by ID.
- Middleware:
restrictTo(["user"])
. - Handler:
handleRating
.
-
POST
/user/login/successfull
- Description: Handles user login.
- Handler:
handlelogin
.
const UserSchema = new mongoose.Schema({
name: {
type: String,
required: true,
},
phone: {
type: Number,
unique: true,
},
email: {
type: String,
required: true,
unique: true,
},
role: {
type: String,
default: "user",
required: true,
},
image: {
type: String,
default:
"https://fiverr-res.cloudinary.com/images/t_main1,q_auto,f_auto,q_auto,f_auto/gigs2/173502583/original/6a346e0505fac7746ebd790a5de335221c42a4a5/draw-a-simple-big-head-cartoon-from-your-photo.png",
},
orderId: { type: mongoose.Schema.Types.ObjectId, ref: "BookedOrder" },
review: [{ type: mongoose.Schema.Types.ObjectId, ref: "Review" }],
});
const DriverSchema = new mongoose.Schema({
name: {
type: String,
},
phone: {
type: Number,
unique: true,
},
email: {
type: String,
unique: true,
},
bikeNum: {
type: String,
unique: true,
},
bikeDesc: {
type: String,
},
role: {
type: String,
default: "driver",
required: true,
},
rating: {
type: Number,
default: 5,
},
image: {
type: String,
default:
"https://fiverr-res.cloudinary.com/images/t_main1,q_auto,f_auto,q_auto,f_auto/gigs2/173502583/original/6a346e0505fac7746ebd790a5de335221c42a4a5/draw-a-simple-big-head-cartoon-from-your-photo.png",
},
orderId: { type: mongoose.Schema.Types.ObjectId, ref: "BookedOrder" },
review: [{ type: mongoose.Schema.Types.ObjectId, ref: "Review" }],
});
const OrderSchema = new mongoose.Schema({
name: {
type: String,
},
price: {
type: Number,
},
pickUp: {
type: String,
},
dropIn: {
type: String,
},
time: {
type: String,
},
isBooked: {
type: Boolean,
},
image: {
type: String,
},
driverData: [{ type: mongoose.Schema.Types.ObjectId, ref: "Driver" }],
userData: { type: mongoose.Schema.Types.ObjectId, ref: "User" },
});
const ReviewSchema = mongoose.Schema({
name: {
type: String,
required: true,
},
comment: {
type: String,
},
rating: {
type: Number,
required: true,
},
image: {
type: String,
},
showIn: {
type: Boolean,
required: true,
},
});
const BookedOrderSchema = new mongoose.Schema({
name: {
type: String,
},
price: {
type: Number,
},
pickUp
- fork the repository into your github account
- clone it into your local system
git clone <repository-url>
docker compose up --watch
- Install the dependicies
npm install
- Add the env variables
MONGO_URL="add-your-mongo-url" SECRET_CODE="ETsledjf340854"
- Start the server
node app.js
ornodemon app.js