Skip to content

Commit

Permalink
chore(core): update GET /configs/jwt-customizer/:tokenPath API error …
Browse files Browse the repository at this point in the history
…handling (#5595)
  • Loading branch information
darcyYe committed Mar 30, 2024
1 parent 7756f50 commit e34cfd8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
8 changes: 3 additions & 5 deletions packages/core/src/libraries/logto-config.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {
LogtoConfigs,
cloudApiIndicator,
cloudConnectionDataGuard,
logtoOidcConfigGuard,
LogtoOidcConfigKey,
jwtCustomizerConfigGuard,
LogtoConfigs,
} from '@logto/schemas';
import type { LogtoOidcConfigType, LogtoJwtTokenKey, CloudConnectionData } from '@logto/schemas';
import chalk from 'chalk';
Expand All @@ -13,10 +13,8 @@ import { z, ZodError } from 'zod';
import RequestError from '#src/errors/RequestError/index.js';
import type Queries from '#src/tenants/Queries.js';
import { consoleLog } from '#src/utils/console.js';
import { convertToIdentifiers } from '#src/utils/sql.js';

export type LogtoConfigLibrary = ReturnType<typeof createLogtoConfigLibrary>;
const { table } = convertToIdentifiers(LogtoConfigs);

export const createLogtoConfigLibrary = ({
logtoConfigs: {
Expand Down Expand Up @@ -87,8 +85,8 @@ export const createLogtoConfigLibrary = ({
// If the record does not exist (`rows` is empty)
if (rows.length === 0) {
throw new RequestError({
code: 'entity.not_exists',
name: table,
code: 'entity.not_exists_with_id',
name: LogtoConfigs.tableSingular,
id: key,
status: 404,
});
Expand Down
8 changes: 4 additions & 4 deletions packages/integration-tests/src/tests/api/logto-config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ describe('admin console sign-in experience', () => {
};

await expectRejects(getJwtCustomizer('access-token'), {
code: 'entity.not_exists',
code: 'entity.not_exists_with_id',
status: 404,
});
await expectRejects(deleteJwtCustomizer('access-token'), {
Expand All @@ -163,7 +163,7 @@ describe('admin console sign-in experience', () => {
);
await expect(deleteJwtCustomizer('access-token')).resolves.not.toThrow();
await expectRejects(getJwtCustomizer('access-token'), {
code: 'entity.not_exists',
code: 'entity.not_exists_with_id',
status: 404,
});
});
Expand All @@ -176,7 +176,7 @@ describe('admin console sign-in experience', () => {
};

await expectRejects(getJwtCustomizer('client-credentials'), {
code: 'entity.not_exists',
code: 'entity.not_exists_with_id',
status: 404,
});
await expectRejects(deleteJwtCustomizer('client-credentials'), {
Expand All @@ -202,7 +202,7 @@ describe('admin console sign-in experience', () => {
);
await expect(deleteJwtCustomizer('client-credentials')).resolves.not.toThrow();
await expectRejects(getJwtCustomizer('client-credentials'), {
code: 'entity.not_exists',
code: 'entity.not_exists_with_id',
status: 404,
});
});
Expand Down

0 comments on commit e34cfd8

Please sign in to comment.