Initial Commit

This commit is contained in:
2026-05-27 23:29:53 +01:00
commit fbc70f96e6
10000 changed files with 1102152 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
// Test-only Hono ContextVariableMap shim — adds the slots normally
// contributed by sibling plugins (`@suaveplan/api-plugin-auth`,
// `@suaveplan/api-tenant`, `@suaveplan/api`) so test files can call
// `c.set("user", ...)`, `c.set("tenant", ...)`, `c.set("requestId", ...)`
// without ts2769 errors when the sibling packages are not direct deps.
import "hono";
declare module "hono" {
interface ContextVariableMap {
user: { id?: string } | null | undefined;
tenant: { id?: string } | null | undefined;
requestId: string;
}
}

View File

@@ -0,0 +1,32 @@
/**
* Test setup for @suaveplan/api-plugin-audit.
*
* Installs a real in-memory OpenTelemetry MeterProvider BEFORE any source
* module imports so the meter resolved on first call binds to it.
*/
import { metrics } from "@opentelemetry/api";
import {
AggregationTemporality,
InMemoryMetricExporter,
MeterProvider,
PeriodicExportingMetricReader,
} from "@opentelemetry/sdk-metrics";
export const testInMemoryMetricExporter = new InMemoryMetricExporter(
AggregationTemporality.CUMULATIVE
);
const reader = new PeriodicExportingMetricReader({
exporter: testInMemoryMetricExporter,
exportIntervalMillis: 60_000,
});
export const testMeterProvider = new MeterProvider({ readers: [reader] });
metrics.setGlobalMeterProvider(testMeterProvider);
export async function flushTestMetrics() {
await testMeterProvider.forceFlush();
const collected = testInMemoryMetricExporter.getMetrics();
testInMemoryMetricExporter.reset();
return collected;
}