refacto: no magic numbers
This commit is contained in:
@@ -4,20 +4,22 @@ import { authenticateRequest } from "./src/auth/verify.ts";
|
||||
|
||||
const router = new Router();
|
||||
|
||||
const PAGINATION = 20
|
||||
|
||||
router.get("/", (ctx) => {
|
||||
ctx.response.body = "Hello world";
|
||||
});
|
||||
|
||||
router.get("/notes", (ctx) => {
|
||||
const cursor = ctx.request.url.searchParams.get("cursor") ?? undefined;
|
||||
const limit = Number(ctx.request.url.searchParams.get("limit")) || 20;
|
||||
const limit = Number(ctx.request.url.searchParams.get("limit")) || PAGINATION;
|
||||
ctx.response.body = getNotes(cursor, limit);
|
||||
});
|
||||
|
||||
router.get("/:did/notes", (ctx) => {
|
||||
const { did } = ctx.params;
|
||||
const cursor = ctx.request.url.searchParams.get("cursor") ?? undefined;
|
||||
const limit = Number(ctx.request.url.searchParams.get("limit")) || 20;
|
||||
const limit = Number(ctx.request.url.searchParams.get("limit")) || PAGINATION;
|
||||
ctx.response.body = getNotesByDid(did, cursor, limit);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user