remove post/user

This commit is contained in:
Michael Fatemi 2021-04-10 15:11:08 -04:00
parent 50013f6340
commit 530a3f54d2
3 changed files with 72 additions and 72 deletions

13
package-lock.json generated
View File

@ -88,6 +88,14 @@
"resolved": "https://registry.npmjs.org/@types/cors/-/cors-2.8.10.tgz",
"integrity": "sha512-C7srjHiVG3Ey1nR6d511dtDkCEjxuN9W1HWAEjGq8kpcwmNM6JJkpC0xvabM7BXTG2wDq8Eu33iH9aQKa7IvLQ=="
},
"@types/dotenv": {
"version": "8.2.0",
"resolved": "https://registry.npmjs.org/@types/dotenv/-/dotenv-8.2.0.tgz",
"integrity": "sha512-ylSC9GhfRH7m1EUXBXofhgx4lUWmFeQDINW5oLuS+gxWdfUeW4zJdeVTYVkexEW+e2VUvlZR2kGnGGipAWR7kw==",
"requires": {
"dotenv": "*"
}
},
"@types/express": {
"version": "4.17.11",
"resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.11.tgz",
@ -242,6 +250,11 @@
"resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz",
"integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA="
},
"dotenv": {
"version": "8.2.0",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-8.2.0.tgz",
"integrity": "sha512-8sJ78ElpbDJBHNeBzUbUVLsqKdccaa/BXF1uPTw3GrvQTBgrQrtObr2mUrE38vzYd8cEv+m/JBfDLioYcfXoaw=="
},
"ee-first": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",

View File

@ -21,6 +21,7 @@
"dependencies": {
"@types/axios": "^0.14.0",
"@types/cors": "^2.8.10",
"@types/dotenv": "^8.2.0",
"@types/express": "^4.17.11",
"@types/node": "^14.14.37",
"@types/simple-oauth2": "^4.1.0",

View File

@ -6,7 +6,7 @@ import {
getUserByID,
groups,
users,
pools
pools,
} from './data';
export const router = Router();
@ -26,19 +26,19 @@ router.get('/user', (req, res) => {
}
});
router.post('/user', (req, res) => {
if (req.body.userID in users) {
res.json({ status: 'error', error: 'already_exists' });
} else {
users[req.body.userID] = {
id: req.body.userID,
username: req.body.username,
first_name: req.body.first_name,
last_name: req.body.last_name,
};
res.json({ status: 'success' });
}
});
// router.post('/user', (req, res) => {
// if (req.body.userID in users) {
// res.json({ status: 'error', error: 'already_exists' });
// } else {
// users[req.body.userID] = {
// id: req.body.userID,
// username: req.body.username,
// first_name: req.body.first_name,
// last_name: req.body.last_name,
// };
// res.json({ status: 'success' });
// }
// });
router.delete('/user', (req, res) => {
delete users[req.body.userID];
@ -61,33 +61,32 @@ router.get('/pool', (req, res) => {
});
router.post('/pool', (req, res) => {
if(req.body.poolID in pools) {
res.json({status: 'error', error: 'already_exists'});
}
else {
pools[req.body.poolID] = {
id: req.body.poolID,
title: req.body.title,
description: req.body.description,
participant_ids: [],
driver_id: 'no driver',
create_time: 'create time',
update_time: 'update time',
comments: [],
group_id: 'no group',
status: 'pending',
capacity: 0,
direction: 'pickup',
author_id: 'no author',
type: 'request'
}
res.json({status: 'success'});
}
if (req.body.poolID in pools) {
res.json({ status: 'error', error: 'already_exists' });
} else {
pools[req.body.poolID] = {
id: req.body.poolID,
title: req.body.title,
description: req.body.description,
participant_ids: [],
driver_id: 'no driver',
create_time: 'create time',
update_time: 'update time',
comments: [],
group_id: 'no group',
status: 'pending',
capacity: 0,
direction: 'pickup',
author_id: 'no author',
type: 'request',
};
res.json({ status: 'success' });
}
});
router.delete('/pool', (req, res) => {
delete pools[req.body.poolID];
res.json({status: 'success'});
delete pools[req.body.poolID];
res.json({ status: 'success' });
});
router.get('/group', (req, res) => {
@ -106,21 +105,20 @@ router.get('/group', (req, res) => {
});
router.post('/group', (req, res) => {
if(req.body.groupID in groups) {
res.json({status: 'error', error: 'already_exists'});
}
else {
groups[req.body.groupID] = {
id: req.body.groupID,
member_ids: []
}
res.json({status: 'success'});
}
if (req.body.groupID in groups) {
res.json({ status: 'error', error: 'already_exists' });
} else {
groups[req.body.groupID] = {
id: req.body.groupID,
member_ids: [],
};
res.json({ status: 'success' });
}
});
router.delete('/group', (req, res) => {
delete groups[req.body.groupID];
res.json({status: 'success'});
delete groups[req.body.groupID];
res.json({ status: 'success' });
});
router.get('/my_pools', (req, res) => {
@ -138,26 +136,14 @@ router.get('/my_pools', (req, res) => {
}
});
router.post('/my_pools', (req, res) => {
if(req.body.groupID in groups) {
res.json({status: 'error', error: 'already_exists'});
}
else {
groups[req.body.groupID] = {
id: req.body.groupID,
member_ids: []
}
res.json({status: 'success'});
}
});
if (req.body.groupID in groups) {
res.json({ status: 'error', error: 'already_exists' });
} else {
groups[req.body.groupID] = {
id: req.body.groupID,
member_ids: [],
};
res.json({ status: 'success' });
}
});