mirror of
https://github.com/myfatemi04/wheelshare-old-backend.git
synced 2025-05-02 16:59:50 -04:00
Add files via upload
This commit is contained in:
parent
e15ef4f453
commit
5b149ee803
45
src/index.ts
45
src/index.ts
|
@ -1,18 +1,10 @@
|
|||
import express from "express";
|
||||
import dotenv from 'dotenv';
|
||||
import { users, groups } from "./data";
|
||||
|
||||
dotenv.config({
|
||||
path: '.env'
|
||||
});
|
||||
import * as express from "express";
|
||||
import { users } from "./data";
|
||||
import { groups } from "./data";
|
||||
|
||||
const app = express();
|
||||
|
||||
app.get("/user", (req, res) => {
|
||||
|
||||
});
|
||||
|
||||
app.post('/user/:userID', (req, res) => {
|
||||
app.get("/user/:userID", (req, res) => {
|
||||
if(!(req.params.userID in users)) {
|
||||
res.send('user ID not found');
|
||||
return;
|
||||
|
@ -20,14 +12,23 @@ app.post('/user/:userID', (req, res) => {
|
|||
res.json(users[req.params.userID]);
|
||||
});
|
||||
|
||||
app.post('/user', (req, res) => {
|
||||
users[req.body.userID] = {
|
||||
id: req.body.userID,
|
||||
first_name: req.body.first_name,
|
||||
last_name: req.body.last_name
|
||||
}
|
||||
});
|
||||
|
||||
app.patch('/user', (req, res) => {
|
||||
|
||||
});
|
||||
|
||||
app.delete('/user', (req, res) => {
|
||||
|
||||
delete users[req.body.userID];
|
||||
});
|
||||
|
||||
|
||||
app.get("/pool", (req, res) => {
|
||||
|
||||
});
|
||||
|
@ -44,13 +45,18 @@ app.delete('/pool', (req, res) => {
|
|||
|
||||
});
|
||||
|
||||
app.get("/group", (req, res) => {
|
||||
|
||||
|
||||
app.get("/group/:groupID", (req, res) => {
|
||||
if(!(req.params.groupID in groups)) {
|
||||
res.send('invalid group id');
|
||||
return;
|
||||
}
|
||||
res.json(groups[req.params.groupID]);
|
||||
});
|
||||
|
||||
app.post('/group', (req, res) => {
|
||||
groups[req.body.title] = {
|
||||
id: 'id 0',
|
||||
id: 'temp id 0',
|
||||
member_ids: []
|
||||
}
|
||||
});
|
||||
|
@ -60,9 +66,10 @@ app.patch('/group', (req, res) => {
|
|||
});
|
||||
|
||||
app.delete('/group', (req, res) => {
|
||||
|
||||
delete groups[req.body.groupID];
|
||||
});
|
||||
|
||||
|
||||
app.get("/join_pool", (req, res) => {
|
||||
|
||||
});
|
||||
|
@ -79,6 +86,4 @@ app.delete('/join_pool', (req, res) => {
|
|||
|
||||
});
|
||||
|
||||
((port = process.env.APP_PORT || 5000) => {
|
||||
app.listen(port, () => void console.log(`Listening on port ${port}`));
|
||||
})();
|
||||
app.listen(80, () => void console.log("Listening on port 80"));
|
||||
|
|
Loading…
Reference in New Issue
Block a user