Skip to content

Commit

Permalink
fixup! feat(ApiKey): add CRUDL for API keys
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukáš Janeček committed Oct 22, 2024
1 parent eced86b commit 21f1621
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions src/administration/api-keys.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ import { Tag } from '@/swagger.js';

export const apiKeysModule: FastifyPluginAsyncJsonSchemaToTs = async (app) => {
app.post<{ Body: ApiKeyCreateBody; Params: ApiKeyCreateParams }>(
'/organization/projects/{project_id}/api_keys',
'/organization/projects/:project_id/api_keys',
{
schema: {
body: apiKeyCreateBodySchema,
Expand All @@ -72,7 +72,7 @@ export const apiKeysModule: FastifyPluginAsyncJsonSchemaToTs = async (app) => {
);

app.get<{ Params: ApiKeyReadParams }>(
'/organization/projects/{project_id}/api_keys//{api_key_id}',
'/organization/projects/:project_id/api_keys/:api_key_id',
{
schema: {
params: apiKeyReadParamsSchema,
Expand All @@ -85,7 +85,7 @@ export const apiKeysModule: FastifyPluginAsyncJsonSchemaToTs = async (app) => {
);

app.post<{ Params: ApiKeyUpdateParams; Body: ApiKeyUpdateBody }>(
'/organization/projects/{project_id}/api_keys/{api_key_id}',
'/organization/projects/:project_id/api_keys/:api_key_id',
{
schema: {
params: apiKeyUpdateParamsSchema,
Expand All @@ -99,7 +99,7 @@ export const apiKeysModule: FastifyPluginAsyncJsonSchemaToTs = async (app) => {
);

app.get<{ Querystring: ApiKeysListQuery; Params: ApiKeyListParams }>(
'/organization/projects/{project_id}/api_keys',
'/organization/projects/:project_id/api_keys',
{
schema: {
querystring: apiKeysListQuerySchema,
Expand All @@ -112,7 +112,7 @@ export const apiKeysModule: FastifyPluginAsyncJsonSchemaToTs = async (app) => {
);

app.delete<{ Params: ApiKeyDeleteParams }>(
'/organization/projects/{project_id}/api_keys/{api_key_id}',
'/organization/projects/:project_id/api_keys/:api_key_id',
{
schema: {
params: apiKeyDeleteParamsSchema,
Expand Down
4 changes: 2 additions & 2 deletions src/administration/api-keys.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export function toDto(apiKey: Loaded<ProjectApiKey>, sensitiveId?: string): ApiK
id: apiKey.id,
name: apiKey.name,
created_at: dayjs(apiKey.createdAt).unix(),
sensitive_id: sensitiveId
sensitive_id: typeof sensitiveId === 'string' ? sensitiveId : undefined
};
}

Expand All @@ -67,7 +67,7 @@ export async function createApiKey({

await ORM.em.persistAndFlush(apiKey);

return toDto(apiKey, key);
return toDto(apiKey, keyValue);
}

export async function readApiKey({
Expand Down
2 changes: 1 addition & 1 deletion src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ try {
app.register(filesModule, { prefix: '/v1' });
app.register(vectorStoresModule, { prefix: '/v1' });
app.register(vectorStoreFilesModule, { prefix: '/v1' });
app.register(apiKeysModule, { prefix: '/v1' });
app.register(projectsModule, { prefix: '/v1' });
app.register(projectUsersModule, { prefix: '/v1' });
app.register(organizationUsersModule, { prefix: '/v1' });
app.register(apiKeysModule, { prefix: '/v1' });

app.register(uiModule, { prefix: '/v1' });

Expand Down

0 comments on commit 21f1621

Please sign in to comment.