mirror of
https://github.com/myfatemi04/wheelshare-old-backend.git
synced 2025-05-03 17:29:50 -04:00
remove post/user
This commit is contained in:
parent
50013f6340
commit
530a3f54d2
13
package-lock.json
generated
13
package-lock.json
generated
|
@ -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",
|
||||
|
|
|
@ -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",
|
||||
|
|
82
src/api.ts
82
src/api.ts
|
@ -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,10 +61,9 @@ router.get('/pool', (req, res) => {
|
|||
});
|
||||
|
||||
router.post('/pool', (req, res) => {
|
||||
if(req.body.poolID in pools) {
|
||||
res.json({status: 'error', error: 'already_exists'});
|
||||
}
|
||||
else {
|
||||
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,
|
||||
|
@ -79,15 +78,15 @@ router.post('/pool', (req, res) => {
|
|||
capacity: 0,
|
||||
direction: 'pickup',
|
||||
author_id: 'no author',
|
||||
type: 'request'
|
||||
}
|
||||
res.json({status: 'success'});
|
||||
type: 'request',
|
||||
};
|
||||
res.json({ status: 'success' });
|
||||
}
|
||||
});
|
||||
|
||||
router.delete('/pool', (req, res) => {
|
||||
delete pools[req.body.poolID];
|
||||
res.json({status: 'success'});
|
||||
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 {
|
||||
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'});
|
||||
member_ids: [],
|
||||
};
|
||||
res.json({ status: 'success' });
|
||||
}
|
||||
});
|
||||
|
||||
router.delete('/group', (req, res) => {
|
||||
delete groups[req.body.groupID];
|
||||
res.json({status: 'success'});
|
||||
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 {
|
||||
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'});
|
||||
member_ids: [],
|
||||
};
|
||||
res.json({ status: 'success' });
|
||||
}
|
||||
});
|
Loading…
Reference in New Issue
Block a user