exposed bknd middlewares to be used for custom routes

This commit is contained in:
dswbx
2025-01-11 15:45:32 +01:00
parent bd4bc14282
commit d8671355a6
11 changed files with 20 additions and 32 deletions

View File

@@ -1,9 +1 @@
import { describe, expect, it } from "bun:test";
import { shouldSkipAuth } from "../../src/auth/middlewares";
describe("auth middleware", () => {
it("should skip auth on asset paths", () => {
expect(shouldSkipAuth(new Request("http://localhost/assets/test.js"))).toBe(true);
expect(shouldSkipAuth(new Request("http://localhost/"))).toBe(false);
});
});

View File

@@ -79,7 +79,7 @@ describe("AppAuth", () => {
}
});
test("registers auth middleware automatically", async () => {
test("registers auth middleware for bknd routes only", async () => {
const app = createApp({
initialConfig: {
auth: {
@@ -101,7 +101,7 @@ describe("AppAuth", () => {
await app.server.request("/api/system/ping");
await app.server.request("/test");
expect(spy.mock.calls.length).toBe(2);
expect(spy.mock.calls.length).toBe(1);
});
test("should allow additional user fields", async () => {