diff --git a/package.json b/package.json index 10e024b..0d53a45 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "test": "jest --bail", "test:watch": "jest --watch --bail", "test:coverage": "yarn test --coverage", - "check-packages": "yarn clean && yarn build && yarn test && yarn lint && yarn type-check", + "check-packages": "yarn clean && yarn build && yarn test && yarn lint && yarn check-types", "bump-version": "lerna --ignore=examples/* version --no-push --exact", "deploy": "lerna publish --conventional-commits --message 'chore: release new versions'", "prerelease": "lerna publish --conventional-prerelease --pre-dist-tag next", diff --git a/packages/core/src/router-builder/createResourceRouter.ts b/packages/core/src/router-builder/createTypedRouter.ts similarity index 94% rename from packages/core/src/router-builder/createResourceRouter.ts rename to packages/core/src/router-builder/createTypedRouter.ts index edd8cc8..48f0398 100644 --- a/packages/core/src/router-builder/createResourceRouter.ts +++ b/packages/core/src/router-builder/createTypedRouter.ts @@ -5,7 +5,7 @@ import { RouteMap, RouterInterface } from '../types'; import { RouterBuilder } from './builder'; import { CreateResourceRouterOptions } from './types'; -export function createResourceRouter< +export function createTypedRouter< Klass extends Resource, Definitions extends RouteMap >( diff --git a/packages/core/src/router-builder/index.ts b/packages/core/src/router-builder/index.ts index 1b7b249..f276945 100644 --- a/packages/core/src/router-builder/index.ts +++ b/packages/core/src/router-builder/index.ts @@ -1,4 +1,4 @@ -export * from './createResourceRouter'; +export * from './createTypedRouter'; export * from './types'; diff --git a/packages/core/test-d/createResourceRouter.types.ts b/packages/core/test-d/createResourceRouter.types.ts index dcbe118..4601fe6 100644 --- a/packages/core/test-d/createResourceRouter.types.ts +++ b/packages/core/test-d/createResourceRouter.types.ts @@ -1,7 +1,7 @@ import { expectType } from 'tsd'; import { - createResourceRouter, + createTypedRouter, ResourceInterface, } from '../src'; import { DummyResource } from '../src/DummyResource'; @@ -11,7 +11,7 @@ interface Animal { name: string; } -const api = createResourceRouter({ +const api = createTypedRouter({ resource: DummyResource, config: { apiRoot: '/api/v1', // Set api root diff --git a/packages/core/test/createResourceRouter.test.ts b/packages/core/test/createTypedRouter.test.ts similarity index 97% rename from packages/core/test/createResourceRouter.test.ts rename to packages/core/test/createTypedRouter.test.ts index 7ea3227..51a82f7 100644 --- a/packages/core/test/createResourceRouter.test.ts +++ b/packages/core/test/createTypedRouter.test.ts @@ -1,13 +1,13 @@ import 'jest-extended'; -import { createResourceRouter } from '../src'; +import { createTypedRouter } from '../src'; import DEFAULTS from '../src/constants'; import { DummyResource } from '../src/DummyResource'; describe('createRouter :: invalid type used', () => { test('invalid type :: top level', () => { expect(() => { - createResourceRouter({ + createTypedRouter({ resource: DummyResource, config: null, routerBuilder: (builder) => ({ @@ -19,7 +19,7 @@ describe('createRouter :: invalid type used', () => { test('invalid type :: nested', () => { expect(() => { - createResourceRouter({ + createTypedRouter({ resource: DummyResource, config: null, routerBuilder: (builder) => ({ @@ -33,7 +33,7 @@ describe('createRouter :: invalid type used', () => { }); describe('createRouter :: string map', () => { - const api = createResourceRouter({ + const api = createTypedRouter({ resource: DummyResource, config: { root: true }, routerBuilder: (builder) => ({ @@ -139,7 +139,7 @@ describe('createRouter :: string map', () => { const res = await api.test.del(); expect(res).toEqual({ ...defaultResponse, - method: 'delete', + method: 'del', url: '/a/', data: {}, }); @@ -166,7 +166,7 @@ describe('createRouter :: string map', () => { }); describe('createRouter :: resource tuple', () => { - const api = createResourceRouter({ + const api = createTypedRouter({ resource: DummyResource, config: null, routerBuilder: (builder) => ({ @@ -209,7 +209,7 @@ describe('createRouter :: resource tuple', () => { }); describe('createRouter :: resource constructor', () => { - const api = createResourceRouter({ + const api = createTypedRouter({ resource: DummyResource, config: { level: 0 }, routerBuilder: (builder) => ({ @@ -254,7 +254,7 @@ describe('createRouter :: resource constructor', () => { }); describe('createRouter :: mixed', () => { - const api = createResourceRouter({ + const api = createTypedRouter({ resource: DummyResource, config: { level: 0, apiRoot: 'https://server1.example.com' }, routerBuilder: (builder) => ({