mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-10-15 10:41:32 +08:00
feat(tasks): add GET API
This commit is contained in:
parent
c0e42e23a6
commit
98dff61305
@ -12,6 +12,7 @@ import type { AttachmentRow, BlobRow, RevisionRow } from "./entities/rows.js";
|
||||
import BBlob from "./entities/bblob.js";
|
||||
import BRecentNote from "./entities/brecent_note.js";
|
||||
import type AbstractBeccaEntity from "./entities/abstract_becca_entity.js";
|
||||
import type BTask from "./entities/btask.js";
|
||||
|
||||
interface AttachmentOpts {
|
||||
includeContentLength?: boolean;
|
||||
@ -32,6 +33,7 @@ export default class Becca {
|
||||
attributeIndex!: Record<string, BAttribute[]>;
|
||||
options!: Record<string, BOption>;
|
||||
etapiTokens!: Record<string, BEtapiToken>;
|
||||
tasks!: Record<string, BTask>;
|
||||
|
||||
allNoteSetCache: NoteSet | null;
|
||||
|
||||
@ -48,6 +50,7 @@ export default class Becca {
|
||||
this.attributeIndex = {};
|
||||
this.options = {};
|
||||
this.etapiTokens = {};
|
||||
this.tasks = {};
|
||||
|
||||
this.dirtyNoteSetCache();
|
||||
|
||||
@ -213,6 +216,10 @@ export default class Becca {
|
||||
return this.etapiTokens[etapiTokenId];
|
||||
}
|
||||
|
||||
getTasks(): BTask[] {
|
||||
return Object.values(this.tasks);
|
||||
}
|
||||
|
||||
getEntity<T extends AbstractBeccaEntity<T>>(entityName: string, entityId: string): AbstractBeccaEntity<T> | null {
|
||||
if (!entityName || !entityId) {
|
||||
return null;
|
||||
|
@ -31,6 +31,7 @@ export default class BTask extends AbstractBeccaEntity<BOption> {
|
||||
}
|
||||
|
||||
this.updateFromRow(row);
|
||||
this.init();
|
||||
}
|
||||
|
||||
get isDeleted() {
|
||||
@ -43,6 +44,16 @@ export default class BTask extends AbstractBeccaEntity<BOption> {
|
||||
this.title = row.title;
|
||||
this.dueDate = row.dueDate;
|
||||
this._isDeleted = !!row.isDeleted;
|
||||
|
||||
if (this.taskId) {
|
||||
this.becca.tasks[this.taskId] = this;
|
||||
}
|
||||
}
|
||||
|
||||
init() {
|
||||
if (this.taskId) {
|
||||
this.becca.tasks[this.taskId] = this;
|
||||
}
|
||||
}
|
||||
|
||||
getPojo() {
|
||||
|
5
src/routes/api/tasks.ts
Normal file
5
src/routes/api/tasks.ts
Normal file
@ -0,0 +1,5 @@
|
||||
import * as tasksService from "../../services/tasks.js";
|
||||
|
||||
export function getTasks() {
|
||||
return tasksService.getTasks();
|
||||
}
|
@ -72,6 +72,7 @@ import etapiSpecRoute from "../etapi/spec.js";
|
||||
import etapiBackupRoute from "../etapi/backup.js";
|
||||
|
||||
import apiDocsRoute from "./api_docs.js";
|
||||
import * as tasksRoute from "./api/tasks.js";
|
||||
|
||||
const MAX_ALLOWED_FILE_SIZE_MB = 250;
|
||||
const GET = "get",
|
||||
@ -279,6 +280,8 @@ function register(app: express.Application) {
|
||||
apiRoute(PATCH, "/api/etapi-tokens/:etapiTokenId", etapiTokensApiRoutes.patchToken);
|
||||
apiRoute(DEL, "/api/etapi-tokens/:etapiTokenId", etapiTokensApiRoutes.deleteToken);
|
||||
|
||||
apiRoute(GET, "/api/tasks", tasksRoute.getTasks);
|
||||
|
||||
// in case of local electron, local calls are allowed unauthenticated, for server they need auth
|
||||
const clipperMiddleware = isElectron ? [] : [auth.checkEtapiToken];
|
||||
|
||||
|
5
src/services/tasks.ts
Normal file
5
src/services/tasks.ts
Normal file
@ -0,0 +1,5 @@
|
||||
import becca from "../becca/becca.js";
|
||||
|
||||
export function getTasks() {
|
||||
return becca.getTasks();
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user