-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathindex.ts
More file actions
47 lines (44 loc) · 1.55 KB
/
index.ts
File metadata and controls
47 lines (44 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import {
createFoundationSimulationServer,
type SimulationHandlers,
type FoundationSimulator,
} from "@simulacrum/foundation-simulator";
import type { ExtendedSimulationStore } from "./store/index.ts";
import { extendStore } from "./store/index.ts";
import type { Router } from "express";
import type { Auth0ExtendStoreInput } from "./store/index.ts";
import { extendRouter } from "./handlers/index.ts";
import {
type Auth0InitialStore,
auth0InitialStoreSchema,
} from "./store/entities.ts";
import { getConfig } from "./config/get-config.ts";
import { type Auth0Configuration } from "./types.ts";
export type Auth0Simulator = (args?: {
debug?: boolean;
initialState?: Auth0InitialStore;
extend?: {
extendStore?: Auth0ExtendStoreInput;
openapiHandlers?: (
simulationStore: ExtendedSimulationStore
) => SimulationHandlers;
extendRouter?: (
router: Router,
simulationStore: ExtendedSimulationStore
) => void;
};
options?: Partial<Auth0Configuration>;
}) => FoundationSimulator<ExtendedSimulationStore>;
export const simulation: Auth0Simulator = (args = {}) => {
const config = getConfig(args.options);
const parsedInitialState = !args?.initialState
? undefined
: auth0InitialStoreSchema.parse(args?.initialState);
return createFoundationSimulationServer({
port: 4400, // default port
protocol: "https",
extendStore: extendStore(parsedInitialState, args?.extend?.extendStore),
extendRouter: extendRouter(config, args.debug),
})();
};
export { auth0UserSchema, defaultUser } from "./store/entities.ts";