From e4608b7df74fb12d1e58092ef84c538ed4a2185d Mon Sep 17 00:00:00 2001 From: dswbx Date: Tue, 1 Apr 2025 13:49:58 +0200 Subject: [PATCH] cosmetics: fixed admin skeleton, use password field on auth, use $console in auth middleware --- app/__test__/api/DataApi.spec.ts | 12 +++++++++++- app/package.json | 4 ++-- app/src/auth/middlewares.ts | 6 +++--- app/src/ui/Admin.tsx | 8 ++++---- app/src/ui/elements/auth/AuthForm.tsx | 4 ++-- 5 files changed, 22 insertions(+), 12 deletions(-) diff --git a/app/__test__/api/DataApi.spec.ts b/app/__test__/api/DataApi.spec.ts index c6bb3df..51786ca 100644 --- a/app/__test__/api/DataApi.spec.ts +++ b/app/__test__/api/DataApi.spec.ts @@ -5,7 +5,8 @@ import { DataApi } from "../../src/data/api/DataApi"; import { DataController } from "../../src/data/api/DataController"; import { dataConfigSchema } from "../../src/data/data-schema"; import * as proto from "../../src/data/prototype"; -import { disableConsoleLog, enableConsoleLog, schemaToEm } from "../helper"; +import { schemaToEm } from "../helper"; +import { disableConsoleLog, enableConsoleLog } from "core/utils/test"; beforeAll(disableConsoleLog); afterAll(enableConsoleLog); @@ -64,6 +65,15 @@ describe("DataApi", () => { const res = await req; expect(res.data).toEqual(payload as any); } + + { + // make sure sort is working + const req = await api.readMany("posts", { + select: ["title"], + sort: "-id", + }); + expect(req.data).toEqual(payload.reverse() as any); + } }); it("updates many", async () => { diff --git a/app/package.json b/app/package.json index 0ddd590..c3d2f55 100644 --- a/app/package.json +++ b/app/package.json @@ -3,7 +3,7 @@ "type": "module", "sideEffects": false, "bin": "./dist/cli/index.js", - "version": "0.11.0-rc.1", + "version": "0.11.0-rc.2", "description": "Lightweight Firebase/Supabase alternative built to run anywhere — incl. Next.js, React Router, Astro, Cloudflare, Bun, Node, AWS Lambda & more.", "homepage": "https://bknd.io", "repository": { @@ -32,7 +32,7 @@ "build:types": "tsc -p tsconfig.build.json --emitDeclarationOnly && tsc-alias", "updater": "bun x npm-check-updates -ui", "cli": "LOCAL=1 bun src/cli/index.ts", - "prepublishOnly": "bun run types && bun run test && bun run build:all && cp ../README.md ./", + "prepublishOnly": "bun run types && bun run test && bun run test:node && bun run build:all && cp ../README.md ./", "postpublish": "rm -f README.md" }, "license": "FSL-1.1-MIT", diff --git a/app/src/auth/middlewares.ts b/app/src/auth/middlewares.ts index 83e64ce..dcd0994 100644 --- a/app/src/auth/middlewares.ts +++ b/app/src/auth/middlewares.ts @@ -1,4 +1,4 @@ -import type { Permission } from "core"; +import { $console, type Permission } from "core"; import { patternMatch } from "core/utils"; import type { Context } from "hono"; import { createMiddleware } from "hono/factory"; @@ -49,7 +49,7 @@ export const auth = (options?: { // make sure to only register once if (authCtx.registered) { skipped = true; - console.warn(`auth middleware already registered for ${getPath(c)}`); + $console.warn(`auth middleware already registered for ${getPath(c)}`); } else { authCtx.registered = true; @@ -93,7 +93,7 @@ export const permission = ( if (app?.module.auth.enabled) { throw new Error(msg); } else { - console.warn(msg); + $console.warn(msg); } } else if (!authCtx.skip) { const guard = app.modules.ctx().guard; diff --git a/app/src/ui/Admin.tsx b/app/src/ui/Admin.tsx index 0312177..59bf859 100644 --- a/app/src/ui/Admin.tsx +++ b/app/src/ui/Admin.tsx @@ -66,15 +66,15 @@ const Skeleton = ({ theme }: { theme?: any }) => { -