compalian
This commit is contained in:
parent
6c3f7b7db9
commit
5559fa8b45
4
.env
4
.env
@ -12,5 +12,5 @@ CLOUDINARY_API_SECRET = "XWtPK6iHcWABNTh2qegrN5Df9OU"
|
|||||||
|
|
||||||
SEND_EMAIL_FROM="chatgpt.airport@gmail.com"
|
SEND_EMAIL_FROM="chatgpt.airport@gmail.com"
|
||||||
|
|
||||||
# AnyTimePrasad(ATM)
|
# chatGpt.Airport
|
||||||
SENDGRID_API_KEY="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"
|
SENDGRID_API_KEY="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"
|
9
app.js
9
app.js
@ -30,9 +30,12 @@ app.use("/api", ProductRouter);
|
|||||||
import orderRoute from './resources/Orders/orderRoute.js'
|
import orderRoute from './resources/Orders/orderRoute.js'
|
||||||
app.use("/api", orderRoute);
|
app.use("/api", orderRoute);
|
||||||
|
|
||||||
//Franchisee
|
//Departure
|
||||||
import FranchiseeRouter from "./resources/Temple/FranchiseeRoute.js";
|
import DepartureRouter from "./resources/Departure/DepartureRoute.js";
|
||||||
app.use("/api/franchisee/", FranchiseeRouter);
|
app.use("/api/departure/", DepartureRouter);
|
||||||
|
//Information
|
||||||
|
import InformationRoute from "./resources/Informations/InformationRoute.js";
|
||||||
|
app.use("/api/information/", InformationRoute);
|
||||||
//state
|
//state
|
||||||
import StateRouter from "./resources/setting/state/state_routes.js";
|
import StateRouter from "./resources/setting/state/state_routes.js";
|
||||||
app.use("/api/state", StateRouter);
|
app.use("/api/state", StateRouter);
|
||||||
|
52
resources/Departure/DepartureController.js
Normal file
52
resources/Departure/DepartureController.js
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
import { Departure } from "./DepartureModel.js"
|
||||||
|
export const AddNewFlight = async (req, res) => {
|
||||||
|
try {
|
||||||
|
if (!req?.user) return res.status(400).json({ message: "please login !" });
|
||||||
|
// console.log(req?.user)
|
||||||
|
|
||||||
|
|
||||||
|
req.body.user = req.user._id
|
||||||
|
const departure = await Departure.create(req.body);
|
||||||
|
|
||||||
|
res.status(201).json({
|
||||||
|
success: true,
|
||||||
|
departure,
|
||||||
|
message: 'few Flight Created',
|
||||||
|
});
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({
|
||||||
|
success: false,
|
||||||
|
message: error.message ? error.message : 'Something went Wrong',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const FindAllFlight = async (req, res) => {
|
||||||
|
try {
|
||||||
|
if (!req?.user) return res.status(400).json({ message: "please login !" });
|
||||||
|
// console.log(req?.user)
|
||||||
|
|
||||||
|
|
||||||
|
const departure = await Departure.find().sort({ createdAt: -1 });
|
||||||
|
if (departure) {
|
||||||
|
return res.status(200).json({
|
||||||
|
success: true,
|
||||||
|
departure,
|
||||||
|
message: 'Fetched All Flight ',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return res.status(404).json({
|
||||||
|
success: true,
|
||||||
|
departure,
|
||||||
|
message: 'No Flight till Now',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({
|
||||||
|
success: false,
|
||||||
|
message: error.message ? error.message : 'Something went Wrong',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
61
resources/Departure/DepartureModel.js
Normal file
61
resources/Departure/DepartureModel.js
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
import mongoose from "mongoose";
|
||||||
|
const { Schema, model } = mongoose;
|
||||||
|
|
||||||
|
const departureSchema = new Schema({
|
||||||
|
FlightNumber: {
|
||||||
|
type: String,
|
||||||
|
maxLength: [25, "FlightNumber cannot exceed 25 characters"],
|
||||||
|
required: true,
|
||||||
|
trim: true,
|
||||||
|
},
|
||||||
|
Airline: {
|
||||||
|
type: String,
|
||||||
|
maxLength: [25, "Airline cannot exceed 25 characters"],
|
||||||
|
required: [true, "Please Enter Airline"],
|
||||||
|
},
|
||||||
|
Destination: {
|
||||||
|
type: String,
|
||||||
|
required: [true, "Please Enter Destination"],
|
||||||
|
maxLength: [25, "Price cannot exceed 25 characters"],
|
||||||
|
},
|
||||||
|
GateNumber: {
|
||||||
|
type: String,
|
||||||
|
required: [true, "Please Enter GateNumber "],
|
||||||
|
maxLength: [3, "GateNumber cannot exceed 3 characters"],
|
||||||
|
},
|
||||||
|
ActualTimeofDeparture: {
|
||||||
|
type: String,
|
||||||
|
required: true
|
||||||
|
|
||||||
|
|
||||||
|
},
|
||||||
|
ScheduledTimeofDeparture: {
|
||||||
|
type: String,
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
EstimatedTimeofDeparture: {
|
||||||
|
|
||||||
|
type: String,
|
||||||
|
required: true
|
||||||
|
|
||||||
|
},
|
||||||
|
Status: {
|
||||||
|
type: String,
|
||||||
|
enum: ["Departed", "OnTime", "Boarding", "Delayed", "Cancelled"],
|
||||||
|
required: true,
|
||||||
|
trim: true,
|
||||||
|
},
|
||||||
|
|
||||||
|
user: {
|
||||||
|
type: Schema.Types.ObjectId,
|
||||||
|
ref: "User"
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}, { timestamps: true });
|
||||||
|
|
||||||
|
export const Departure = model("Departure", departureSchema);
|
18
resources/Departure/DepartureRoute.js
Normal file
18
resources/Departure/DepartureRoute.js
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
|
||||||
|
import express from 'express'
|
||||||
|
import { AddNewFlight, FindAllFlight } from "./DepartureController.js";
|
||||||
|
import { isAuthenticatedUser, authorizeRoles } from "../../middlewares/auth.js";
|
||||||
|
|
||||||
|
const router = express.Router()
|
||||||
|
|
||||||
|
router.route("/flight/new").post(isAuthenticatedUser, authorizeRoles("admin"), AddNewFlight)
|
||||||
|
router.route("/flight/getAll").get(isAuthenticatedUser, authorizeRoles("admin"), FindAllFlight)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// router.route("/product/getAll/").get(getAllProduct)
|
||||||
|
|
||||||
|
export default router
|
53
resources/Informations/InformationController.js
Normal file
53
resources/Informations/InformationController.js
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
|
||||||
|
import { Information } from "./InformationModel.js"
|
||||||
|
export const AddNewnIformation = async (req, res) => {
|
||||||
|
try {
|
||||||
|
if (!req?.user) return res.status(400).json({ message: "please login !" });
|
||||||
|
// console.log(req?.user)
|
||||||
|
|
||||||
|
|
||||||
|
req.body.user = req.user._id
|
||||||
|
const information = await Information.create(req.body);
|
||||||
|
|
||||||
|
res.status(201).json({
|
||||||
|
success: true,
|
||||||
|
information,
|
||||||
|
message: 'Information Added',
|
||||||
|
});
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({
|
||||||
|
success: false,
|
||||||
|
message: error.message ? error.message : 'Something went Wrong',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const FindAllInformation = async (req, res) => {
|
||||||
|
try {
|
||||||
|
if (!req?.user) return res.status(400).json({ message: "please login !" });
|
||||||
|
// console.log(req?.user)
|
||||||
|
|
||||||
|
|
||||||
|
const information = await Information.find().sort({ createdAt: -1 });
|
||||||
|
if (information) {
|
||||||
|
return res.status(200).json({
|
||||||
|
success: true,
|
||||||
|
information,
|
||||||
|
message: 'Fetched All Information',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return res.status(404).json({
|
||||||
|
success: true,
|
||||||
|
|
||||||
|
message: 'No Information till Now',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({
|
||||||
|
success: false,
|
||||||
|
message: error.message ? error.message : 'Something went Wrong',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
27
resources/Informations/InformationModel.js
Normal file
27
resources/Informations/InformationModel.js
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
import mongoose from "mongoose";
|
||||||
|
|
||||||
|
const { Schema, model } = mongoose;
|
||||||
|
|
||||||
|
const informationSchema = new mongoose.Schema(
|
||||||
|
{
|
||||||
|
|
||||||
|
title: {
|
||||||
|
type: String,
|
||||||
|
maxLength: [150, "title cannot exceed 25 characters"],
|
||||||
|
required: [true, "Please Enter title "],
|
||||||
|
},
|
||||||
|
description: {
|
||||||
|
type: String,
|
||||||
|
maxLength: [500, "description cannot exceed 500 characters"],
|
||||||
|
required: [true, "Please Enter product description"],
|
||||||
|
},
|
||||||
|
user: {
|
||||||
|
type: Schema.Types.ObjectId,
|
||||||
|
ref: "User"
|
||||||
|
},
|
||||||
|
|
||||||
|
},
|
||||||
|
{ timestamps: true, versionKey: false }
|
||||||
|
);
|
||||||
|
|
||||||
|
export const Information = mongoose.model("Information", informationSchema);
|
18
resources/Informations/InformationRoute.js
Normal file
18
resources/Informations/InformationRoute.js
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
|
||||||
|
import express from 'express'
|
||||||
|
import { isAuthenticatedUser, authorizeRoles } from "../../middlewares/auth.js";
|
||||||
|
import { AddNewnIformation, FindAllInformation } from './InformationController.js';
|
||||||
|
|
||||||
|
const router = express.Router()
|
||||||
|
|
||||||
|
router.route("/new").post(isAuthenticatedUser, authorizeRoles("admin"), AddNewnIformation)
|
||||||
|
router.route("/getAll").get(isAuthenticatedUser, authorizeRoles("admin"), FindAllInformation)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// router.route("/product/getAll/").get(getAllProduct)
|
||||||
|
|
||||||
|
export default router
|
@ -129,7 +129,7 @@ export const forgotPassword = async (req, res, next) => {
|
|||||||
|
|
||||||
from: `${process.env.SEND_EMAIL_FROM}`, // Change to your verified sender
|
from: `${process.env.SEND_EMAIL_FROM}`, // Change to your verified sender
|
||||||
|
|
||||||
subject: `ATP Password Recovery`,
|
subject: `ChatGpt Airport Password Recovery`,
|
||||||
html: `your new password is: <br/> <strong> ${passwords}</strong><br/><br/>If you have not requested this email then, please ignore it.`
|
html: `your new password is: <br/> <strong> ${passwords}</strong><br/><br/>If you have not requested this email then, please ignore it.`
|
||||||
|
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user