backend returns done with boolean type instead of number
This commit is contained in:
@@ -8,6 +8,12 @@ const db = drizzle("file:local.db");
|
||||
const app = express();
|
||||
const userId = "Detlef";
|
||||
|
||||
type Prettify<T> = {
|
||||
[K in keyof T]: T[K];
|
||||
} & {};
|
||||
|
||||
type TaskResponse = Prettify<Omit<typeof task.$inferSelect, 'done'> & { done: boolean }>
|
||||
|
||||
app.use(cors())
|
||||
app.use(express.json());
|
||||
|
||||
@@ -16,9 +22,10 @@ app.get('/', (req, res) => {
|
||||
});
|
||||
|
||||
app.get('/tasks', async (req, res) => {
|
||||
const tasks = await db.select().from(task)
|
||||
console.log(tasks)
|
||||
res.send(tasks);
|
||||
const tasks: typeof task.$inferSelect[] = await db.select().from(task)
|
||||
res.send(tasks.map<TaskResponse>(task => {
|
||||
return { ...task, done: task.done === 1 }
|
||||
}));
|
||||
});
|
||||
|
||||
app.get('/events', async (req, res) => {
|
||||
|
||||
Reference in New Issue
Block a user