├── .env ├── routes ├── Team.js ├── Video.js ├── AboutUs.js ├── Gallery.js ├── Maps.js ├── ContactUs.js ├── RentPropertyDetail.js ├── SalePropertyDetail.js ├── Admin.js └── SubmittedPropertyRequests.js ├── models ├── Gallery.models.js ├── Maps.models.js ├── Video.models.js ├── Admin.models.js ├── Team.models.js ├── ContactUs.models.js ├── AboutUs.models.js ├── RentPropertyDetail.models.js ├── SalePropertyDetail.models.js └── SubmittedPropertyRequests.models.js └── index.js /.env: -------------------------------------------------------------------------------- 1 | ATLAS_URI=mongodb+srv://nikky:nikky@cluster0.ipn2jk0.mongodb.net/myFirstDatabase?retryWrites=true&w=majority 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /routes/Team.js: -------------------------------------------------------------------------------- 1 | const router = require("express").Router(); 2 | let TeamDB = require("../models/Team.models"); 3 | 4 | router.route("/").get((req, res) => { 5 | TeamDB.find() 6 | .then((Team) => res.json(Team)) 7 | .catch((err) => res.status(400).json("Error: " + err)); 8 | }); 9 | 10 | module.exports = router; 11 | -------------------------------------------------------------------------------- /routes/Video.js: -------------------------------------------------------------------------------- 1 | const router = require("express").Router(); 2 | let VideoDB = require("../models/Video.models"); 3 | 4 | router.route("/").get((req, res) => { 5 | VideoDB.find() 6 | .then((Video) => res.json(Video)) 7 | .catch((err) => res.status(400).json("Error: " + err)); 8 | }); 9 | 10 | module.exports = router; 11 | -------------------------------------------------------------------------------- /routes/AboutUs.js: -------------------------------------------------------------------------------- 1 | const router = require("express").Router(); 2 | let AboutUsDB = require("../models/AboutUs.models"); 3 | 4 | router.route("/").get((req, res) => { 5 | AboutUsDB.findOne() 6 | .then((AboutUs) => res.json(AboutUs)) 7 | .catch((err) => res.status(400).json("Error: " + err)); 8 | }); 9 | 10 | module.exports = router; 11 | -------------------------------------------------------------------------------- /routes/Gallery.js: -------------------------------------------------------------------------------- 1 | const router = require("express").Router(); 2 | let GalleryDB = require("../models/Gallery.models"); 3 | 4 | router.route("/").get((req, res) => { 5 | GalleryDB.find() 6 | .then((Gallery) => res.json(Gallery)) 7 | .catch((err) => res.status(400).json("Error: " + err)); 8 | }); 9 | 10 | module.exports = router; 11 | -------------------------------------------------------------------------------- /routes/Maps.js: -------------------------------------------------------------------------------- 1 | const router = require("express").Router(); 2 | let MapsDB = require("../models/Maps.models"); 3 | 4 | router.route("/").get((req, res) => { 5 | MapsDB.find() 6 | .then((Maps) => res.json(Maps)) 7 | .catch((err) => res.status(400).json("Error: " + err)); 8 | console.log(res); 9 | }); 10 | 11 | module.exports = router; 12 | -------------------------------------------------------------------------------- /models/Gallery.models.js: -------------------------------------------------------------------------------- 1 | const mongoose = require("mongoose"); 2 | const Schema = mongoose.Schema; 3 | 4 | const GallerySchema = new Schema( 5 | { 6 | image: { type: String, required: true }, 7 | }, 8 | { 9 | timestamps: true, 10 | } 11 | ); 12 | 13 | const Gallery = mongoose.model("Gallery", GallerySchema); 14 | module.exports = Gallery; 15 | -------------------------------------------------------------------------------- /routes/ContactUs.js: -------------------------------------------------------------------------------- 1 | const router = require("express").Router(); 2 | let ContactUsDB = require("../models/contactUs.models"); 3 | 4 | router.route("/").get((req, res) => { 5 | ContactUsDB.findOne() 6 | .then((ContactUs) => res.json(ContactUs)) 7 | .catch((err) => res.status(400).json("Error: " + err)); 8 | }); 9 | 10 | module.exports = router; 11 | -------------------------------------------------------------------------------- /models/Maps.models.js: -------------------------------------------------------------------------------- 1 | const mongoose = require("mongoose"); 2 | const Schema = mongoose.Schema; 3 | 4 | const MapsSchema = new Schema( 5 | { 6 | image: { type: String, required: true }, 7 | link: { type: String, required: true }, 8 | }, 9 | { 10 | timestamps: true, 11 | } 12 | ); 13 | 14 | const Maps = mongoose.model("Maps", MapsSchema); 15 | module.exports = Maps; 16 | -------------------------------------------------------------------------------- /models/Video.models.js: -------------------------------------------------------------------------------- 1 | const mongoose = require("mongoose"); 2 | const Schema = mongoose.Schema; 3 | 4 | const VideoSchema = new Schema( 5 | { 6 | VideoTitle: { type: String, required: true }, 7 | VideoDescription: { type: String, required: true }, 8 | VideoLink: { type: String, required: true }, 9 | }, 10 | { 11 | timestamps: true, 12 | } 13 | ); 14 | 15 | const Video = mongoose.model("Video", VideoSchema); 16 | module.exports = Video; 17 | -------------------------------------------------------------------------------- /models/Admin.models.js: -------------------------------------------------------------------------------- 1 | const mongoose = require("mongoose"); 2 | const Schema = mongoose.Schema; 3 | 4 | const adminSchema = new Schema( 5 | { 6 | username: { type: String, required: true, unique: true, minlength: 3 }, 7 | password: { type: String, required: true, minlength: 3 }, 8 | email: { type: String, required: true, minlength: 5 }, 9 | }, 10 | { 11 | timestamps: true, 12 | } 13 | ); 14 | 15 | const Admin = mongoose.model("Admin", adminSchema); 16 | module.exports = Admin; 17 | -------------------------------------------------------------------------------- /models/Team.models.js: -------------------------------------------------------------------------------- 1 | const mongoose = require("mongoose"); 2 | const Schema = mongoose.Schema; 3 | 4 | const TeamSchema = new Schema( 5 | { 6 | image: { type: String, required: true, minlength: 1 }, 7 | 8 | name: { type: String, required: true, minlength: 1 }, 9 | role: { type: String }, 10 | 11 | facebook: { type: String, minlength: 5 }, 12 | twitter: { type: String, minlength: 5 }, 13 | instagram: { type: String, minlength: 5 }, 14 | linkedIn: { type: String, minlength: 5 }, 15 | }, 16 | { 17 | timestamps: true, 18 | } 19 | ); 20 | 21 | const Team = mongoose.model("Team", TeamSchema); 22 | module.exports = Team; 23 | -------------------------------------------------------------------------------- /routes/RentPropertyDetail.js: -------------------------------------------------------------------------------- 1 | const router = require("express").Router(); 2 | let RentPropertyDB = require("../models/RentPropertyDetail.models"); 3 | 4 | router.route("/").get((req, res) => { 5 | RentPropertyDB.find() 6 | .then((RentProperty) => res.json(RentProperty)) 7 | .catch((err) => res.status(400).json("Error: " + err)); 8 | }); 9 | 10 | router.route("/property-details-rent/:id").get(function (req, res) { 11 | const id = req.params.id; 12 | RentPropertyDB.findById(id, function (err, property) { 13 | if (!property) { 14 | return res.json("Property not found :(").end(); 15 | } 16 | return res.json(property).end(); 17 | }); 18 | }); 19 | 20 | module.exports = router; 21 | -------------------------------------------------------------------------------- /routes/SalePropertyDetail.js: -------------------------------------------------------------------------------- 1 | const router = require("express").Router(); 2 | let SalePropertyDB = require("../models/SalePropertyDetail.models"); 3 | 4 | router.route("/").get((req, res) => { 5 | SalePropertyDB.find() 6 | .then((SaleProperty) => res.json(SaleProperty)) 7 | .catch((err) => res.status(400).json("Error: " + err)); 8 | }); 9 | 10 | router.route("/property-details-sale/:id").get(function (req, res) { 11 | const id = req.params.id; 12 | SalePropertyDB.findById(id, function (err, property) { 13 | if (!property) { 14 | return res.json("Property not found :(").end(); 15 | } 16 | return res.json(property).end(); 17 | }); 18 | }); 19 | 20 | module.exports = router; 21 | -------------------------------------------------------------------------------- /routes/Admin.js: -------------------------------------------------------------------------------- 1 | const router = require("express").Router(); 2 | let AdminDB = require("../models/Admin.models"); 3 | 4 | router.route("/login").post(async (req, res) => { 5 | try { 6 | const username = req.body.username; 7 | const password = req.body.password; 8 | 9 | let admin = await AdminDB.findOne({ username }); 10 | 11 | if (!admin) return res.json("User not found"); 12 | 13 | if (!(password === admin.password)) 14 | return res.json("Password doesn't match"); 15 | 16 | return res.json("Login Successful"); 17 | } catch { 18 | return res.status(400).json("An Unexpected Error Occurred"); 19 | } 20 | }); 21 | 22 | // router.route('/resetPassword').post(async (req,res) => { 23 | // const username = req.body.username; 24 | 25 | // let admin = await AdminDB.findOne({username}); 26 | 27 | // if(!admin) 28 | // return res.status(400).json("User Not Exist"); 29 | 30 | // admin.pass 31 | // }); 32 | 33 | module.exports = router; 34 | -------------------------------------------------------------------------------- /routes/SubmittedPropertyRequests.js: -------------------------------------------------------------------------------- 1 | let mongoose = require("mongoose"), 2 | express = require("express"), 3 | router = express.Router(); 4 | 5 | let SubmittedPropertyRequests = require("../models/SubmittedPropertyRequests.models"); 6 | 7 | router.post("/create-propertyRequest", (req, res, next) => { 8 | SubmittedPropertyRequests.create(req.body, (error, data) => { 9 | if (error) { 10 | return next(error); 11 | } else { 12 | res.json(data); 13 | } 14 | }); 15 | }); 16 | 17 | router.get("/", (req, res, next) => { 18 | SubmittedPropertyRequests.find((error, data) => { 19 | if (error) { 20 | return next(error); 21 | } else { 22 | res.json(data); 23 | } 24 | }); 25 | }); 26 | 27 | router.delete("/delete-propertyRequest/:id", (req, res, next) => { 28 | SubmittedPropertyRequests.findByIdAndRemove(req.params.id, (error, data) => { 29 | if (error) { 30 | return next(error); 31 | } else { 32 | res.status(200).json({ 33 | msg: "Property post request removed successfully", 34 | }); 35 | } 36 | }); 37 | }); 38 | 39 | module.exports = router; 40 | -------------------------------------------------------------------------------- /models/ContactUs.models.js: -------------------------------------------------------------------------------- 1 | const mongoose = require("mongoose"); 2 | const Schema = mongoose.Schema; 3 | 4 | const contactUsSchema = new Schema( 5 | { 6 | description: { type: String, required: true, minlength: 50 }, 7 | location: { type: String, required: true, minlength: 10 }, 8 | phoneNumber1: { type: String, required: true, minlength: 5 }, 9 | phoneNumber2: { type: String, unique: true, minlength: 5 }, 10 | phoneNumber3: { type: String, unique: true, minlength: 5 }, 11 | 12 | days1: { type: String, required: true, minlength: 5 }, 13 | days2: { type: String, minlength: 3 }, 14 | days3: { type: String, minlength: 3 }, 15 | 16 | timings1: { type: String, required: true, minlength: 5 }, 17 | timings2: { type: String, minlength: 1 }, 18 | timings3: { type: String, minlength: 1 }, 19 | 20 | facebook: { type: String, minlength: 5 }, 21 | twitter: { type: String, minlength: 5 }, 22 | instagram: { type: String, minlength: 5 }, 23 | skype: { type: String, minlength: 5 }, 24 | email: { type: String, minlength: 5 }, 25 | 26 | locationLink: { type: String, required: true, minlength: 5 }, 27 | }, 28 | { 29 | timestamps: true, 30 | } 31 | ); 32 | 33 | const ContactUs = mongoose.model("ContactUS", contactUsSchema); 34 | module.exports = ContactUs; 35 | -------------------------------------------------------------------------------- /models/AboutUs.models.js: -------------------------------------------------------------------------------- 1 | const mongoose = require("mongoose"); 2 | const Schema = mongoose.Schema; 3 | 4 | const AboutUsSchema = new Schema( 5 | { 6 | title1: { type: String, minlength: 50 }, 7 | title2: { type: String, minlength: 10 }, 8 | description: { type: String, minlength: 50 }, 9 | list1: { type: String, minlength: 10 }, 10 | list2: { type: String, minlength: 10 }, 11 | list3: { type: String, minlength: 10 }, 12 | list4: { type: String, minlength: 10 }, 13 | list5: { type: String, minlength: 10 }, 14 | list6: { type: String, minlength: 10 }, 15 | list7: { type: String, minlength: 10 }, 16 | 17 | SellProperty: { type: String, minlength: 50 }, 18 | DailyApartment: { type: String, minlength: 50 }, 19 | FamilyHouse: { type: String, minlength: 50 }, 20 | 21 | testimonial: { type: String, minlength: 10 }, 22 | ClientSay: { type: String, minlength: 50 }, 23 | line1: { type: String, minlength: 50 }, 24 | say1: { type: String, minlength: 50 }, 25 | say2: { type: String, minlength: 50 }, 26 | 27 | ClientName1: { type: String, minlength: 5 }, 28 | ClientName2: { type: String, minlength: 5 }, 29 | ClientPosition1: { type: String, minlength: 5 }, 30 | ClientPosition2: { type: String, minlength: 5 }, 31 | }, 32 | { 33 | timestamps: true, 34 | } 35 | ); 36 | 37 | const AboutUs = mongoose.model("AboutUS", AboutUsSchema); 38 | module.exports = AboutUs; 39 | -------------------------------------------------------------------------------- /models/RentPropertyDetail.models.js: -------------------------------------------------------------------------------- 1 | const mongoose = require("mongoose"); 2 | const Schema = mongoose.Schema; 3 | 4 | const RentPropertyDetailSchema = new Schema( 5 | { 6 | _id: Schema.Types.ObjectId, 7 | PropertyTitle: { type: String, minlength: 3, required: true }, 8 | PropertyTagline: { type: String, minlength: 3, required: true }, 9 | Address: { type: String, minlength: 5, required: true }, 10 | City: { type: String, minlength: 3, required: true }, 11 | Price: { type: Number, minLength: 5, required: true }, 12 | DatePosted: { type: Date, required: true }, 13 | Description: { type: String, minlength: 50, required: true }, 14 | PropertyMapLocation: { type: String, required: true }, 15 | 16 | MainImage: { type: String, required: true }, 17 | Images: [{ type: String, required: true }], 18 | 19 | Bedrooms: { type: Number, required: true }, 20 | Livingrooms: { type: Number, required: true }, 21 | TypeOfProperty: { type: String, required: true }, 22 | Bathrooms: { type: Number, required: true }, 23 | TotalRooms: { type: Number, required: true }, 24 | YearBuilt: { type: Date, required: true }, 25 | Kitchens: { type: Number, required: true }, 26 | AreaSqFt: { type: Number, required: true }, 27 | Owner: { type: String, required: true }, 28 | 29 | Amenities: [{ type: String, required: true }], 30 | 31 | Places: [{ type: String, required: true }], 32 | PopularTags: [{ type: String, required: true }], 33 | }, 34 | { 35 | timestamps: true, 36 | } 37 | ); 38 | 39 | const RentPropertyDetail = mongoose.model( 40 | "RentPropertyDetail", 41 | RentPropertyDetailSchema 42 | ); 43 | module.exports = RentPropertyDetail; 44 | -------------------------------------------------------------------------------- /models/SalePropertyDetail.models.js: -------------------------------------------------------------------------------- 1 | const mongoose = require("mongoose"); 2 | const Schema = mongoose.Schema; 3 | 4 | const SalePropertyDetailSchema = new Schema( 5 | { 6 | _id: Schema.Types.ObjectId, 7 | PropertyTitle: { type: String, minlength: 3, required: true }, 8 | PropertyTagline: { type: String, minlength: 3, required: true }, 9 | Address: { type: String, minlength: 5, required: true }, 10 | City: { type: String, minlength: 3, required: true }, 11 | Price: { type: Number, minLength: 5, required: true }, 12 | DatePosted: { type: Date, required: true }, 13 | Description: { type: String, minlength: 50, required: true }, 14 | PropertyMapLocation: { type: String, required: true }, 15 | 16 | MainImage: { type: String, required: true }, 17 | Images: [{ type: String, required: true }], 18 | 19 | Bedrooms: { type: Number, required: true }, 20 | Livingrooms: { type: Number, required: true }, 21 | TypeOfProperty: { type: String, required: true }, 22 | Bathrooms: { type: Number, required: true }, 23 | TotalRooms: { type: Number, required: true }, 24 | YearBuilt: { type: Date, required: true }, //A Date or Number? 25 | Kitchens: { type: Number, required: true }, 26 | AreaSqFt: { type: Number, required: true }, 27 | Owner: { type: String, required: true }, 28 | 29 | Amenities: [{ type: String, required: true }], 30 | 31 | Places: [{ type: String, required: true }], 32 | PopularTags: [{ type: String, required: true }], 33 | }, 34 | { 35 | timestamps: true, 36 | } 37 | ); 38 | 39 | const SalePropertyDetail = mongoose.model( 40 | "SalePropertyDetail", 41 | SalePropertyDetailSchema 42 | ); 43 | module.exports = SalePropertyDetail; 44 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | const express = require("express"); 2 | const cors = require("cors"); 3 | const moongoose = require("mongoose"); 4 | 5 | require("dotenv").config(); 6 | 7 | const app = express(); 8 | const port = process.env.PORT || 5000; 9 | 10 | app.use(cors()); 11 | app.use(express.json()); 12 | 13 | const DB_uri = process.env.ATLAS_URI; 14 | moongoose.connect(DB_uri); 15 | const connection = moongoose.connection; 16 | connection.once("open", () => { 17 | console.log("Mongo DB connection established sucessfully"); 18 | }); 19 | 20 | const AdminRouter = require("./routes/Admin"); 21 | const ContactUsRouter = require("./routes/ContactUs"); 22 | const AboutUsRouter = require("./routes/AboutUs"); 23 | const TeamRouter = require("./routes/Team"); 24 | const GalleryRouter = require("./routes/Gallery"); 25 | const VideoRouter = require("./routes/Video"); 26 | const MapsRouter = require("./routes/Maps"); 27 | const RentPropertyDetailRouter = require("./routes/RentPropertyDetail"); 28 | const SalePropertyDetailRouter = require("./routes/SalePropertyDetail"); 29 | const SubmittedPropertyRequestsRouter = require("./routes/SubmittedPropertyRequests"); 30 | 31 | 32 | app.use("/Admin", AdminRouter); 33 | app.use("/ContactUs", ContactUsRouter); 34 | app.use("/AboutUs", AboutUsRouter); 35 | app.use("/Team", TeamRouter); 36 | app.use("/Gallery", GalleryRouter); 37 | app.use("/Video", VideoRouter); 38 | app.use("/Maps", MapsRouter); 39 | app.use("/RentPropertyDetail", RentPropertyDetailRouter); 40 | app.use("/SalePropertyDetail", SalePropertyDetailRouter); 41 | app.use("/SubmittedPropertyRequests", SubmittedPropertyRequestsRouter); 42 | 43 | app.use(express.static('build')) 44 | app.listen(port, () => { 45 | console.log(`Server is running on port: ${port}`); 46 | }); 47 | -------------------------------------------------------------------------------- /models/SubmittedPropertyRequests.models.js: -------------------------------------------------------------------------------- 1 | const mongoose = require("mongoose"); 2 | const Schema = mongoose.Schema; 3 | 4 | const SubmittedPropertyRequestsSchema = new Schema( 5 | { 6 | PropertyTitle: { type: String, minlength: 3, required: true }, 7 | PropertyTagline: { type: String, minlength: 3, required: true }, 8 | Address: { type: String, minlength: 5, required: true }, 9 | City: { type: String, minlength: 3, required: true }, 10 | Price: { type: Number, minLength: 5, required: true }, 11 | DatePosted: { type: Date, required: true }, 12 | Description: { type: String, minlength: 10, required: true }, 13 | PropertyMapLocation: { type: String, required: true }, 14 | 15 | MainImage: { type: String, required: true }, 16 | Images: [{ type: String, required: true }], 17 | 18 | Bedrooms: { type: Number, required: true }, 19 | Livingrooms: { type: Number, required: true }, 20 | TypeOfProperty: { type: String, required: true }, 21 | Bathrooms: { type: Number, required: true }, 22 | TotalRooms: { type: Number, required: true }, 23 | YearBuilt: { type: Date, required: true }, //A Date or Number? 24 | Kitchens: { type: Number, required: true }, 25 | AreaSqFt: { type: Number, required: true }, 26 | Owner: { type: String, required: true }, 27 | 28 | Amenities: [{ type: String, required: true }], 29 | 30 | Places: [{ type: String, required: true }], 31 | PopularTags: [{ type: String, required: true }], 32 | PropertyCategory: { type: String, required: true }, 33 | }, 34 | { 35 | timestamps: true, 36 | } 37 | ); 38 | 39 | const SubmittedPropertyRequests = mongoose.model( 40 | "SubmittedPropertyRequests", 41 | SubmittedPropertyRequestsSchema 42 | ); 43 | module.exports = SubmittedPropertyRequests; 44 | --------------------------------------------------------------------------------