Skip to content

Build your personal knowledge base with Trilium Notes

server-ts: Address requested changes

Elian Doran138be84e452a
diff --git a/src/etapi/notes.ts b/src/etapi/notes.ts
index fcb2d314f7..620e9f3d8a 100644
--- a/src/etapi/notes.ts
+++ b/src/etapi/notes.ts
@@ -239,6 +239,10 @@ function parseBoolean(obj: any, name: string) {
}
function parseOrderDirection(obj: any, name: string) {
+ if (!(name in obj)) {
+ return undefined;
+ }
+
const integer = parseInt(obj[name]);
if (!['asc', 'desc'].includes(obj[name])) {
diff --git a/src/etapi/spec.ts b/src/etapi/spec.ts
index ed8a555a50..530249d463 100644
--- a/src/etapi/spec.ts
+++ b/src/etapi/spec.ts
@@ -4,7 +4,7 @@ import fs = require('fs');
import path = require('path');
const specPath = path.join(__dirname, 'etapi.openapi.yaml');
-let spec: any = null;
+let spec: string | null = null;
function register(router: Router) {
router.get('/etapi/etapi.openapi.yaml', (req, res, next) => {
diff --git a/src/etapi/validators.ts b/src/etapi/validators.ts
index 485bd8d333..a8e98882e1 100644
--- a/src/etapi/validators.ts
+++ b/src/etapi/validators.ts
@@ -24,7 +24,7 @@ function isString(obj: ValidatorArg) {
}
function isLocalDateTime(obj: ValidatorArg) {
- if (obj === undefined || obj === null || typeof obj !== "string") {
+ if (typeof obj !== "string") {
return;
}
@@ -32,7 +32,7 @@ function isLocalDateTime(obj: ValidatorArg) {
}
function isUtcDateTime(obj: ValidatorArg) {
- if (obj === undefined || obj === null || typeof obj !== "string") {
+ if (typeof obj !== "string") {
return;
}