Skip to content

Commit

Permalink
backend setup done
Browse files Browse the repository at this point in the history
  • Loading branch information
SanchitGeez committed Jun 7, 2023
1 parent e0d30f8 commit ad6d244
Show file tree
Hide file tree
Showing 9 changed files with 3,110 additions and 145 deletions.
1 change: 1 addition & 0 deletions backend/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
MONGODB_URI = mongodb://127.0.0.1:27017/byteee
52 changes: 52 additions & 0 deletions backend/CRUD.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
[{
"_id": {
"$oid": "6221e9ff711c42195b3e8e81"
},
"companyName": "Atlantic IT Solutions",
"phone": "251-911-603566",
"email": "info@atlanticplc.com",
"location": "Wello Sefer, Addis Ababa",
"link": "https://atlanticplc.com",
"description": "Atlantic IT Solutions is an ICT Company established in early 2008 GC in Ethiopia. Our company provides a range of IT solutions to automate and facilitate your company activities. We have highly skilled, specialized and professional team to take care of your projects.\n\nWe provide Website Development, Custom Software Development, Website Hosting and Business Email Hosting solutions, to mention some.\n\nThe majority of our clients include companies like Logistics, Contractors, Hotels, Manufacturers, Importers, Exporters, Associations, NGOs and other Industries. We are committed to our clients’ requirements and fulfill their needs in a professional and most economical way. Our ultimate aim is to give full satisfaction to our clients."
},{
"_id": {
"$oid": "6221eaa1711c42195b3e8e8b"
},
"companyName": "Pasqua Giuseppe Aluminum & Metal Works PLC",
"phone": "251-114-420760",
"email": "info@pasquagiuseppe.com",
"location": "Next to St. Joseph Church, Addis Ababa",
"link": "https://pasquagiuseppe.com",
"description": "Pasqua Giuseppe PLC established in 1965 as a Steel Fabrication, Aluminum and Glass Assembling Company. Since its establishment, it has diversified its reach in various industrial sectors.\n\nPasqua Giuseppe PLC is one of the pioneer company in the introduction of Aluminum Products in the construction sector.\n\nWe have been Fabricating and Supplying different size Tankers, Agricultural Trailers and Steel Structures for National & International market. We have been satisfying the growing demand of Tankers for Oil companies and Trailers for Commercial Farmers."
},{
"_id": {
"$oid": "6221eac7711c42195b3e8e90"
},
"companyName": "adrasha.com - Ethiopian Business Direcctory",
"phone": "251-911-603566",
"email": "info@adrasha.com",
"location": "Wello Sefer, Addis Ababa",
"link": "https://adrasha.com",
"description": "adrasha.com is an online Ethiopian Business Directory Platform where Businesses list their profile and reach out Thousands of Customers.\n\nWhether your Business is in Automotive, Construction, Health, Hospitality, Import Export, Manufacturing, Trading or Service Industry, a listing on adrasha.com will increase your visibility & customers will find you with multiple listing features.\n\nGet Listed and let your Business Operate 24×7.\n\nኢትዮጵያ ዉስጥ ከ 23 ሚልየን በላይ ህዝብ ኢንተርኔት ተጠቃሚ እንዳለ ያዉቃሉ? ድርጅቶን adrasha.com ላይ በመመዝገብ ዲጂታል ዓለሙን ይቀላቀሉ፣ ብዙዎችን በኢንተርኔት ይድረሱ ፣ ተጨማሪ ደምበኛ ያፍሩ።"
},{
"_id": {
"$oid": "6221eafc711c42195b3e8e95"
},
"companyName": "CGF Business Group",
"phone": "251-114-166268",
"email": "cgfbg@yahoo.com",
"location": "KirkosSub-city | Wereda 06 | Gotera Area| Baleker Tower 6th Floor",
"link": "https://www.cgfbg.com/",
"description": "Our Business Groups aims to provide our valuable customers with high quality genuine products that they deserve. It is one of our core values to maintain a customer centered healthy relationship so as to show a steady and successful growth.\n\nWe believe that our customers are our stakeholders that is why we keep maintaining our intact communications to learn from them in order to let us always be abreast and champions in the stage of dynamic market as usual.\n\nThe newly introduced technologies, innovations and marketing strategy are the secrets of our success to our customers' satisfaction."
},{
"_id": {
"$oid": "6225f780e0696f30edaa17e5"
},
"companyName": "Hibir Academy",
"phone": "251-116-465665",
"email": "info@hibiracademy.com",
"location": "Gurd Shola Behind Beshale Hotel, Addis Ababa",
"link": "https://hibiracademy.com/",
"description": "Choose Hibir Academy Our Project Based Learning held in the state-of-the-art comfortable classes will nurture your kid’s independent thinking and make them a leader of Future World!\n\nWhy Hibir Academy\n\n✅Project Based Learning\n✅ Nurturing critical and independent thinking\n✅ Wide range of extracurricular and after school activities by professional trainers and coaches\n✅ Comfortable class rooms equipped with state-of-the-art facilities to increase teacher-student interactions\n✅ Committed teachers and support staff\n\nThe Values that unite our School Community are:\n\n- Integrity\n- Excellence\n- Curiosity\n- Respect\n- Compassion\n- Responsibility\n\nCome and Visit Us! \n\nGurd Shola Behind Beshale Hotel, Addis Ababa\n☎️Call: +251-116-465665 or ? +251-978-815277\n#hibiracademy #preschools #schools #education #learning #parents #mom #dads #schoolinaddisababa #addisababa",
"__v": 0
}]
68 changes: 68 additions & 0 deletions backend/controllers/crudController.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
const Crud = require("../models/crudModel");

// Display All CRUD Data
const crud_index = (req, res) => {
Crud.find(function (err, cruds) {
res.json(cruds);
});
};

// Create New CRUD
const crud_create_post = (req, res) => {
let crud = new Crud(req.body);
crud
.save()
.then((crud) => {
res.send(crud);
})
.catch(function (err) {
res.status(422).send("Crud add failed");
});
};

// Show a particular CRUD Detail by Id
const crud_details = (req, res) => {
Crud.findById(req.params.id, function (err, crud) {
if (!crud) {
res.status(404).send("No result found");
} else {
res.json(crud);
}
});
};

// Update CRUD Detail by Id
const crud_update = (req, res) => {
Crud.findByIdAndUpdate(req.params.id, req.body)
.then(function () {
res.json("Crud updated");
})
.catch(function (err) {
res.status(422).send("Crud update failed.");
});
};

// Delete CRUD Detail by Id
const crud_delete = (req, res) => {
Crud.findById(req.params.id, function (err, crud) {
if (!crud) {
res.status(404).send("Crud not found");
} else {
Crud.findByIdAndRemove(req.params.id)
.then(function () {
res.status(200).json("Crud deleted");
})
.catch(function (err) {
res.status(400).send("Crud delete failed.");
});
}
});
};

module.exports = {
crud_index,
crud_details,
crud_create_post,
crud_update,
crud_delete,
};
9 changes: 9 additions & 0 deletions backend/db.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require("dotenv").config();
const mongoose = require("mongoose");

module.exports = () => {
const connection = mongoose
.connect(process.env.MONGODB_URI)
.then((result) => console.log("Connected to database"))
.catch((err) => console.log("could not connect to database",err));
};
23 changes: 23 additions & 0 deletions backend/models/crudModel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const mongoose = require("mongoose");

const crudSchema = new mongoose.Schema({
subject: {
type: String

},
topic: {
type: String

},
date: {
type: Number


},
month: {
type: Number

}
});

module.exports = mongoose.model("Crud", crudSchema, "Cruds");
Loading

0 comments on commit ad6d244

Please sign in to comment.