Skip to content

Commit

Permalink
chore: Rename createResourceRouter -> createTypedRouter
Browse files Browse the repository at this point in the history
Signed-off-by: Jorgen Ader <[email protected]>
  • Loading branch information
jorgenader committed Nov 19, 2024
1 parent dcbc1c1 commit f80775d
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<any, any, any, any>,
Definitions extends RouteMap
>(
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/router-builder/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export * from './createResourceRouter';
export * from './createTypedRouter';

export * from './types';

Expand Down
4 changes: 2 additions & 2 deletions packages/core/test-d/createResourceRouter.types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { expectType } from 'tsd';

import {
createResourceRouter,
createTypedRouter,
ResourceInterface,
} from '../src';
import { DummyResource } from '../src/DummyResource';
Expand All @@ -11,7 +11,7 @@ interface Animal {
name: string;
}

const api = createResourceRouter({
const api = createTypedRouter({
resource: DummyResource,
config: {
apiRoot: '/api/v1', // Set api root
Expand Down
Original file line number Diff line number Diff line change
@@ -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) => ({
Expand All @@ -19,7 +19,7 @@ describe('createRouter :: invalid type used', () => {

test('invalid type :: nested', () => {
expect(() => {
createResourceRouter({
createTypedRouter({
resource: DummyResource,
config: null,
routerBuilder: (builder) => ({
Expand All @@ -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) => ({
Expand Down Expand Up @@ -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: {},
});
Expand All @@ -166,7 +166,7 @@ describe('createRouter :: string map', () => {
});

describe('createRouter :: resource tuple', () => {
const api = createResourceRouter({
const api = createTypedRouter({
resource: DummyResource,
config: null,
routerBuilder: (builder) => ({
Expand Down Expand Up @@ -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) => ({
Expand Down Expand Up @@ -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) => ({
Expand Down

0 comments on commit f80775d

Please sign in to comment.