From 1c45315918e46b97363eaf503a03a3746ffbf7d0 Mon Sep 17 00:00:00 2001
From: Ashwanth K <cb.en.u4cse19305@cb.students.amrita.edu>
Date: Sun, 27 Dec 2020 20:46:11 +0530
Subject: [PATCH] Upload New File

---
 routes/admin.js | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
 create mode 100644 routes/admin.js

diff --git a/routes/admin.js b/routes/admin.js
new file mode 100644
index 0000000..ff797a7
--- /dev/null
+++ b/routes/admin.js
@@ -0,0 +1,28 @@
+const router = require('express').Router();
+let Admin = require('../model/admin.model');
+
+router.route('/').get((req, res) => {
+  Admin.find()
+    .then(Admins => res.json(Admins))
+    .catch(err => res.status(400).json('Error: ' + err));
+});
+
+router.route('/add').post((req, res) => {
+  const admin_id = req.body.admin_id;
+  const name = req.body.name;
+  const email = req.body.email;
+  const password = req.body.password;
+
+  const newAdmin = new Admin({_id: admin_id,name,email,password});
+
+  newAdmin.save()
+    .then(() => res.json('Admin added!'))
+    .catch(err => res.status(400).json('Error: ' + err));
+});
+
+router.route('/:id').get((req, res) => {
+  Admin.findById(req.params.id)
+    .then(Admins => res.json(Admins))
+    .catch(err => res.status(400).json('Error: ' + err));
+});
+module.exports = router;
\ No newline at end of file
-- 
GitLab