1
backend/.gitignore
vendored
1
backend/.gitignore
vendored
@@ -1,3 +1,4 @@
|
|||||||
node_modules
|
node_modules
|
||||||
local.db
|
local.db
|
||||||
drizzle
|
drizzle
|
||||||
|
bun.lockb
|
||||||
|
|||||||
@@ -17,12 +17,11 @@ app.get('/', (req, res) => {
|
|||||||
|
|
||||||
app.get('/tasks', async(req, res) => {
|
app.get('/tasks', async(req, res) => {
|
||||||
const tasks = await db.select().from(task)
|
const tasks = await db.select().from(task)
|
||||||
console.log(tasks)
|
res.status(200).send(tasks);
|
||||||
res.send(tasks);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get('/events', async(req, res) => {
|
app.get('/events', async(req, res) => {
|
||||||
res.send(await db.select().from(event))
|
res.status(200).send(await db.select().from(event))
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get('/user/:id', (req, res) => {
|
app.get('/user/:id', (req, res) => {
|
||||||
@@ -80,7 +79,6 @@ app.post('/task', async(req, res) => {
|
|||||||
app.post('/event', async(req, res) => {
|
app.post('/event', async(req, res) => {
|
||||||
|
|
||||||
const newEvent: typeof event.$inferInsert = req.body
|
const newEvent: typeof event.$inferInsert = req.body
|
||||||
newEvent.description = ""
|
|
||||||
newEvent.userid = userId
|
newEvent.userid = userId
|
||||||
|
|
||||||
const returnedEvent = await db.insert(event).values(newEvent).returning()
|
const returnedEvent = await db.insert(event).values(newEvent).returning()
|
||||||
@@ -91,24 +89,30 @@ app.post('/event', async(req, res) => {
|
|||||||
|
|
||||||
app.put('/task', (req, res) => {
|
app.put('/task', (req, res) => {
|
||||||
|
|
||||||
const updatedTask = req.body;
|
const id = parseInt(req.params['id']);
|
||||||
|
const updatedTask: Partial<typeof task.$inferSelect> = req.body
|
||||||
|
|
||||||
//Validate (having id)
|
if (id == null) {
|
||||||
|
res.status(400).send({error: 'Needs an id'});
|
||||||
//const updatedTaskWithId = db.updateTask(updatedTask)
|
return;
|
||||||
|
}
|
||||||
|
db.update(task).set(updatedTask).where(eq(task.id, id))
|
||||||
|
|
||||||
res.status(200).json(updatedTask);
|
res.status(200).json(updatedTask);
|
||||||
});
|
});
|
||||||
|
|
||||||
app.put('/event', (req, res) => {
|
app.put('/event', (req, res) => {
|
||||||
const updatedEvent = req.body;
|
|
||||||
|
|
||||||
//Validate (having id)
|
const id = parseInt(req.params['id']);
|
||||||
|
const updatedEvent: Partial<typeof event.$inferSelect> = req.body
|
||||||
|
|
||||||
//const updatedEventWithId = db.updateEvent(updatedEvent)
|
if (id == null) {
|
||||||
|
res.status(400).send({error: 'Needs an id'});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
db.update(event).set(updatedEvent).where(eq(event.id, id))
|
||||||
|
|
||||||
res.status(200).json(updatedEvent);
|
res.status(200).json(updatedEvent);});
|
||||||
});
|
|
||||||
|
|
||||||
app.delete('/task/:id', async(req, res) => {
|
app.delete('/task/:id', async(req, res) => {
|
||||||
const id = parseInt(req.params['id']);
|
const id = parseInt(req.params['id']);
|
||||||
|
|||||||
1
web/.gitignore
vendored
1
web/.gitignore
vendored
@@ -25,3 +25,4 @@ logs
|
|||||||
|
|
||||||
# bun
|
# bun
|
||||||
package-lock.json
|
package-lock.json
|
||||||
|
bun.lockb
|
||||||
|
|||||||
Reference in New Issue
Block a user