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 app = express();
|
||||||
const userId = "Detlef";
|
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(cors())
|
||||||
app.use(express.json());
|
app.use(express.json());
|
||||||
|
|
||||||
@@ -16,9 +22,10 @@ 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: typeof task.$inferSelect[] = await db.select().from(task)
|
||||||
console.log(tasks)
|
res.send(tasks.map<TaskResponse>(task => {
|
||||||
res.send(tasks);
|
return { ...task, done: task.done === 1 }
|
||||||
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get('/events', async (req, res) => {
|
app.get('/events', async (req, res) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user