Skip to content

Commit 07917a2

Browse files
committed
fix type signature
1 parent db4f866 commit 07917a2

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/config.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
import { AppRoles, RunEnvironment } from "./roles.js";
2+
import { OriginFunction } from "@fastify/cors";
23

3-
type GroupRoleMapping = Record<string, AppRoles[]>;
4-
type AzureRoleMapping = Record<string, AppRoles[]>;
4+
// From @fastify/cors
5+
type ArrayOfValueOrArray<T> = Array<ValueOrArray<T>>;
6+
type OriginType = string | boolean | RegExp;
7+
type ValueOrArray<T> = T | ArrayOfValueOrArray<T>;
8+
9+
type GroupRoleMapping = Record<string, readonly AppRoles[]>;
10+
type AzureRoleMapping = Record<string, readonly AppRoles[]>;
511

612
export type ConfigType = {
713
GroupRoleMapping: GroupRoleMapping;
814
AzureRoleMapping: AzureRoleMapping;
9-
ValidCorsOrigins: (string | RegExp)[];
15+
ValidCorsOrigins: ValueOrArray<OriginType> | OriginFunction;
1016
AadValidClientId: string;
1117
};
1218

@@ -60,6 +66,6 @@ const environmentConfig: EnvironmentConfigType = {
6066
],
6167
AadValidClientId: "5e08cf0f-53bb-4e09-9df2-e9bdc3467296",
6268
},
63-
} as const;
69+
};
6470

6571
export { genericConfig, environmentConfig };

tests/live/events.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { expect, test } from "vitest";
22
import { InternalServerError } from "../../src/errors/index.js";
3-
import { EventGetResponse } from "../../src/routes/events.js";
3+
import { EventsGetResponse } from "../../src/routes/events.js";
44

55
const appKey = process.env.APPLICATION_KEY;
66
if (!appKey) {
@@ -12,6 +12,6 @@ const baseEndpoint = `https://${appKey}.aws.qa.acmuiuc.org`;
1212
test("getting events", async () => {
1313
const response = await fetch(`${baseEndpoint}/api/v1/events`);
1414
expect(response.status).toBe(200);
15-
const responseJson = (await response.json()) as EventGetResponse;
15+
const responseJson = (await response.json()) as EventsGetResponse;
1616
expect(responseJson.length).greaterThan(0);
1717
});

0 commit comments

Comments
 (0)