feat(tasks): add POST API

This commit is contained in:
Elian Doran 2025-02-18 19:30:02 +02:00
parent 98dff61305
commit 17f9fa7e89
No known key found for this signature in database
5 changed files with 27 additions and 4 deletions

View File

@ -16,7 +16,7 @@ export default class BTask extends AbstractBeccaEntity<BOption> {
return [ "taskId", "parentNoteId", "title", "dueDate", "isDone", "isDeleted" ];
}
taskId!: string;
taskId?: string;
parentNoteId!: string;
title!: string;
dueDate?: string;
@ -43,6 +43,7 @@ export default class BTask extends AbstractBeccaEntity<BOption> {
this.parentNoteId = row.parentNoteId;
this.title = row.title;
this.dueDate = row.dueDate;
this.isDone = !!row.isDeleted;
this._isDeleted = !!row.isDeleted;
if (this.taskId) {

View File

@ -138,10 +138,10 @@ export interface NoteRow {
}
export interface TaskRow {
taskId: string;
taskId?: string;
parentNoteId: string;
title: string;
dueDate?: string;
isDone: boolean;
isDeleted: boolean;
isDone?: boolean;
isDeleted?: boolean;
}

View File

@ -1,5 +1,10 @@
import type { Request } from "express";
import * as tasksService from "../../services/tasks.js";
export function getTasks() {
return tasksService.getTasks();
}
export function createNewTask(req: Request) {
return tasksService.createNewTask(req.body);
}

View File

@ -281,6 +281,7 @@ function register(app: express.Application) {
apiRoute(DEL, "/api/etapi-tokens/:etapiTokenId", etapiTokensApiRoutes.deleteToken);
apiRoute(GET, "/api/tasks", tasksRoute.getTasks);
apiRoute(PST, "/api/tasks", tasksRoute.createNewTask);
// in case of local electron, local calls are allowed unauthenticated, for server they need auth
const clipperMiddleware = isElectron ? [] : [auth.checkEtapiToken];

View File

@ -1,5 +1,21 @@
import becca from "../becca/becca.js";
import BTask from "../becca/entities/btask.js";
export function getTasks() {
return becca.getTasks();
}
interface CreateTaskParams {
parentNoteId: string;
title: string;
dueDate?: string;
}
export function createNewTask(params: CreateTaskParams) {
const task = new BTask(params);
task.save();
return {
task
}
}