aboutsummaryrefslogtreecommitdiffstats
path: root/OLD/csci4131/hw7/api
diff options
context:
space:
mode:
authorMatt Strapp <matt@mattstrapp.net>2022-05-24 11:18:46 -0500
committerMatt Strapp <matt@mattstrapp.net>2022-05-24 11:19:55 -0500
commit7a73162607544204032aa66cce755daf21edebda (patch)
tree58578e01f15f34a855d99c32898db9d7a1603e67 /OLD/csci4131/hw7/api
parentdo some stuff (diff)
downloadhomework-7a73162607544204032aa66cce755daf21edebda.tar
homework-7a73162607544204032aa66cce755daf21edebda.tar.gz
homework-7a73162607544204032aa66cce755daf21edebda.tar.bz2
homework-7a73162607544204032aa66cce755daf21edebda.tar.lz
homework-7a73162607544204032aa66cce755daf21edebda.tar.xz
homework-7a73162607544204032aa66cce755daf21edebda.tar.zst
homework-7a73162607544204032aa66cce755daf21edebda.zip
Graduate
Signed-off-by: Matt Strapp <matt@mattstrapp.net>
Diffstat (limited to 'OLD/csci4131/hw7/api')
-rw-r--r--OLD/csci4131/hw7/api/utilities.js64
1 files changed, 0 insertions, 64 deletions
diff --git a/OLD/csci4131/hw7/api/utilities.js b/OLD/csci4131/hw7/api/utilities.js
deleted file mode 100644
index 12e06aa..0000000
--- a/OLD/csci4131/hw7/api/utilities.js
+++ /dev/null
@@ -1,64 +0,0 @@
-const express = require('express')
-const db = require ('../dbio')
-const router = express.Router()
-router.use(express.urlencoded({ extended: true }))
-
-router.get('/contacts', function (req, res) {
- db.getContacts().then(function(table) {
- res.send(table)
- });
-});
-
-router.post('/login', async function(req, res) {
- var loginInfo = req.body;
- var login = loginInfo.login;
- var pwd = loginInfo.password;
- let rows = [];
-
- // Query the database tbl_login with login and hashed password
- db.query(login, pwd).then(function(rows) {
- // Provided there is no error, and the results set is assigned to a variable named rows:
- if (rows.length >= 1) {// the length should be 0 or 1, but this will work for now
- //success, set the session, return success
- req.session.user = login;
- res.json({ status: 'success' });
- } else {
- res.json({ status: 'fail' });
- }
- });
-
-});
-
-router.get('/logout', function(req, res) {
- if(!req.session.user) {
- res.send('Session not started, can not logout!');
- } else {
- req.session.destroy();
- res.redirect('/login');
- }
-});
-
-router.post('/addContact', function(req, res) {
- var contact = req.body;
- db.addContact(contact).then(function(r) {
- res.send({flag: r});
- }).catch(function() {
-
- })
-});
-
-router.post('/updateContact', function(req, res) {
- var edit = req.body;
- db.editContact(edit).then(function(f) {
- res.send({flag:f});
- });
-})
-
-router.post('/deleteContact', function(req, res) {
- var contact = req.body.name;
- db.deleteContact(contact).then(function(r) {
- res.send({flag: r});
- })
-})
-
-module.exports = router;