Reorganize repo structure and standards references
This commit is contained in:
1 parent
3cb93a81be
commit
be2054274d
5885 files changed
+2588
-195
No files matched your search
@@ -0,0 +1,55 @@
|
||||
import { describe, expect, test } from "vitest";
|
||||
import { getDomainRoutingConfig, hostMatches, normalizeHost } from "./routing.js";
|
||||
|
||||
describe("routing config", () => {
|
||||
test("uses local subdomain defaults", () => {
|
||||
expect(getDomainRoutingConfig({})).toEqual({
|
||||
appBaseDomain: "localhost",
|
||||
webAppHost: "app.localhost",
|
||||
adminAppHost: "admin.localhost",
|
||||
apiHost: "api.localhost",
|
||||
protocol: "http",
|
||||
});
|
||||
});
|
||||
|
||||
test("preserves local dev ports on derived hosts", () => {
|
||||
expect(getDomainRoutingConfig({ APP_BASE_DOMAIN: "localhost:3000" })).toMatchObject({
|
||||
webAppHost: "app.localhost:3000",
|
||||
adminAppHost: "admin.localhost:3000",
|
||||
apiHost: "api.localhost:3000",
|
||||
});
|
||||
});
|
||||
|
||||
test("normalizes explicit hosts", () => {
|
||||
expect(normalizeHost("https://APP.example.com/path")).toBe("app.example.com");
|
||||
expect(hostMatches("https://app.example.com", "app.example.com")).toBe(true);
|
||||
});
|
||||
|
||||
test("uses explicit app, admin, api, base domain, and protocol hosts", () => {
|
||||
expect(
|
||||
getDomainRoutingConfig({
|
||||
APP_BASE_DOMAIN: "Example.com",
|
||||
WEB_APP_HOST: "https://APP.example.com/ignored/path",
|
||||
ADMIN_APP_HOST: "ADMIN.example.com:8443",
|
||||
API_HOST: "https://API.example.com/v1",
|
||||
APP_PROTOCOL: "http",
|
||||
})
|
||||
).toEqual({
|
||||
appBaseDomain: "example.com",
|
||||
webAppHost: "app.example.com",
|
||||
adminAppHost: "admin.example.com:8443",
|
||||
apiHost: "api.example.com",
|
||||
protocol: "http",
|
||||
});
|
||||
});
|
||||
|
||||
test("derives canonical subdomains and https for non-local base domains", () => {
|
||||
expect(getDomainRoutingConfig({ APP_BASE_DOMAIN: "example.com" })).toMatchObject({
|
||||
appBaseDomain: "example.com",
|
||||
webAppHost: "app.example.com",
|
||||
adminAppHost: "admin.example.com",
|
||||
apiHost: "api.example.com",
|
||||
protocol: "https",
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user