diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml new file mode 100644 index 0000000..3fc7ffa --- /dev/null +++ b/.github/workflows/pull-request.yml @@ -0,0 +1,37 @@ +name: Release + +on: + pull_request: + branches: + - main + +jobs: + release: + name: Release + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Use pnpm 8.x + uses: pnpm/action-setup@v2 + with: + version: 8 + + - name: Use Node.js 20.x + uses: actions/setup-node@v3 + with: + node-version: 20 + cache: 'pnpm' + + - name: Install Dependencies + run: pnpm install + + - name: Biome CI + run: pnpm exec biome ci . + + - name: Test + run: pnpm test + + - name: Type Check + run: pnpm exec tsc --noEmit diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a99a227..6b1b0af 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -30,6 +30,9 @@ jobs: - name: Biome CI run: pnpm exec biome ci . + - name: Test + run: pnpm test + - name: Build run: pnpm build diff --git a/src/accept.ts b/src/accept.ts index 65a6288..e21b787 100644 --- a/src/accept.ts +++ b/src/accept.ts @@ -8,7 +8,7 @@ type AcceptMediaType = { acceptExt: Record; }; -type Accept = AcceptMediaType[]; +export type Accept = AcceptMediaType[]; const asciiRange = (start: number, end: number): string => { let chars = ""; @@ -30,7 +30,7 @@ const QCHAR = `\t ${VCHAR} ${OBS_TEXT}`; type RawParameter = [string, string]; -class AcceptParser { +export class AcceptParser { private static readonly default: AcceptMediaType = { type: "*", subType: "*", diff --git a/src/request.ts b/src/request.ts index 310f6e7..cead32c 100644 --- a/src/request.ts +++ b/src/request.ts @@ -240,7 +240,6 @@ export const parseCreateRequest = < }; export type ParseUpdateRequestOptions< - TId extends string, TType extends string, TAttributesSchema extends z.SomeZodObject, TRelationshipsSchema extends z.SomeZodObject | undefined, @@ -262,9 +261,8 @@ export const parseUpdateRequest = < TRelationshipsSchema extends z.SomeZodObject | undefined, >( id: TId, - type: TType, koaContext: Context, - options: ParseUpdateRequestOptions, + options: ParseUpdateRequestOptions, ): ParseUpdateRequestResult => { return parseDataRequest(fixedIdSchema(id), koaContext, options); }; diff --git a/test/headers.test.ts b/test/headers.test.ts index 972f14d..bac248b 100644 --- a/test/headers.test.ts +++ b/test/headers.test.ts @@ -1,7 +1,8 @@ import { describe, expect, it } from "vitest"; -import { type Accept, parseAccept } from "../src/headers.js"; +import { AcceptParser } from "../src/accept.js"; +import type { Accept } from "../src/accept.js"; -describe("parseAccept", () => { +describe("AcceptParser", () => { const validHeaders: [string, string, Accept][] = [ ["empty", " \t ", [{ type: "*", subType: "*", parameters: {}, weight: 1, acceptExt: {} }]], [ @@ -126,7 +127,7 @@ describe("parseAccept", () => { for (const [name, header, expected] of validHeaders) { it(`should match ${name}`, () => { - const actual = parseAccept(header); + const actual = AcceptParser.parse(header); expect(actual).toEqual(expected); }); } @@ -153,7 +154,7 @@ describe("parseAccept", () => { for (const [name, header, expectedMessage] of invalidHeaders) { it(`should throw error on ${name}`, () => { - expect(() => parseAccept(header)).toThrow(expectedMessage); + expect(() => AcceptParser.parse(header)).toThrow(expectedMessage); }); } });