resolved conflicts

This commit is contained in:
2025-07-04 16:58:36 +02:00
3 changed files with 69 additions and 62 deletions

1
backend/.gitignore vendored
View File

@@ -1,3 +1,4 @@
node_modules node_modules
local.db local.db
drizzle drizzle
bun.lockb

View File

@@ -23,13 +23,13 @@ app.get('/', (req, res) => {
app.get('/tasks', async (req, res) => { app.get('/tasks', async (req, res) => {
const tasks: typeof task.$inferSelect[] = await db.select().from(task) const tasks: typeof task.$inferSelect[] = await db.select().from(task)
res.send(tasks.map<TaskResponse>(task => { res.status(200).send(tasks.map<TaskResponse>(task => {
return { ...task, done: task.done === 1 } return { ...task, done: task.done === 1 }
})); }));
}); });
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) => {
@@ -87,7 +87,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()
@@ -98,24 +97,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
View File

@@ -25,3 +25,4 @@ logs
# bun # bun
package-lock.json package-lock.json
bun.lockb