Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file removed App.js
Empty file.
174 changes: 173 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
{
"dependencies": {
"axios": "^0.24.0",
"express": "^4.17.1",
"mongodb": "^4.1.3",
"mongoose": "^6.0.12",
"node": "^17.0.1",
"nodemon": "^2.0.14",
"react": "^17.0.2"
"react": "^17.0.2",
"react-router-dom": "^6.0.0"
}
}
66 changes: 66 additions & 0 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
//App variables Barakat22

const express = require("express");
const mongoose = require("mongoose");
const userController = require("./Routes/userController");
//var cors = require('cors');
// THIS IS WRONG NEVER DO THAT !! Only for the task we put the DB Link here!! NEVER DO THAAAT AGAIN !!

//App variables
const app = express();
const port = process.env.PORT || "8000";
const User = require("./Models/User");
const Flight = require("./Models/Flight");

//"mongodb+srv://dbGamal_123:Barakat22@aclflights.higdx.mongodb.net/ACLflights?retryWrites=true&w=majority";

//"mongodb+srv://dbGamal_123:Barakat22@aclflights.higdx.mongodb.net/ACL?retryWrites=true&w=majority";

const MongoURI =
"mongodb+srv://alaa:1234@cluster0.6ulyk.mongodb.net/myFirstDatabase?retryWrites=true&w=majority";

// #Importing the userController
//app.use(cors({ origin: true, credentials: true }));
app.use(express.urlencoded({ extended: true }));
app.use(express.json()); // To parse the incoming requests with JSON payloads// configurations
// Mongo DB
mongoose
.connect(MongoURI, { useNewUrlParser: true, useUnifiedTopology: true })
.then((result) => console.log("MongoDB is now connected"))
.catch((err) => console.log(err));

// #Routing to usercontroller here

//app.post('/add-user', userController.addUser)
app.post("/add-Flight", userController.addFlight);
app.get("/view-flights", userController.viewFlights);

app.get(
"/search-specific-flights/:flightNumber,departureTime,arrivalTime,dateOfFlight,airportTerminals",
userController.getFlight
);

app.put("/update-flight/:id", userController.updateFlight);
app.delete("/delete-flight/:id", userController.deleteFlight);

app.get("/addAdmin", (req, res) => {
const user = new User({
FirstName: "Adminstrator",
LastName: "Kris",
Email: "Jimmy.Kris@yahoo.com,",
DateOfBirth: "12/01/1998",
LivesIn: "cairo",
Password: "12345678",
PhoneNumber: "01023456778",
Gender: "male",
});

user.save().then((result) => {
res.send("inserted");
});
});

// Starting server
app.listen(port, () => {
console.log(`Listening to requests on http://localhost:${port}`);
});
Loading