mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-29 11:02:28 +08:00
feat(tasks): add POST API
This commit is contained in:
parent
98dff61305
commit
17f9fa7e89
@ -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) {
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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];
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user