0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-02-17 22:04:19 -05:00

Merge pull request #5232 from logto-io/gao-get-delete-invitation

feat(core): get and delete org invitation by id
This commit is contained in:
Gao Sun 2024-01-15 11:40:41 +08:00 committed by GitHub
commit ca24e20f6a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 50 additions and 22 deletions

View file

@ -17,6 +17,48 @@
}
}
}
},
"/api/organization-invitations/{id}": {
"get": {
"summary": "Get organization invitation",
"description": "Get an organization invitation by ID.",
"parameters": [
{
"name": "id",
"in": "path",
"description": "The organization invitation ID.",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "The organization invitation, also contains the organization roles to be assigned to the user when they accept the invitation, and the corresponding magic link data."
}
}
},
"delete": {
"summary": "Delete organization invitation",
"description": "Delete an organization invitation by ID.",
"parameters": [
{
"name": "id",
"in": "path",
"description": "The organization invitation ID.",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"204": {
"description": "The organization invitation was deleted successfully."
}
}
}
}
}
}

View file

@ -1,9 +1,6 @@
import { OrganizationInvitations, organizationInvitationEntityGuard } from '@logto/schemas';
import Router, { type IRouterParamContext } from 'koa-router';
import { OrganizationInvitations } from '@logto/schemas';
import koaGuard from '#src/middleware/koa-guard.js';
import koaPagination from '#src/middleware/koa-pagination.js';
import { tableToPathname } from '#src/utils/SchemaRouter.js';
import SchemaRouter from '#src/utils/SchemaRouter.js';
import { type AuthedRouter, type RouterInitArgs } from '../types.js';
@ -17,24 +14,12 @@ export default function organizationInvitationRoutes<T extends AuthedRouter>(
},
]: RouterInitArgs<T>
) {
const router = new Router<unknown, IRouterParamContext>({
prefix: '/' + tableToPathname(OrganizationInvitations.table),
const router = new SchemaRouter(OrganizationInvitations, invitations, {
disabled: {
post: true,
patchById: true,
},
});
router.get(
'/',
koaPagination(),
koaGuard({ response: organizationInvitationEntityGuard.array(), status: [200] }),
async (ctx, next) => {
const { limit, offset } = ctx.pagination;
const [count, entities] = await invitations.findAll(limit, offset);
ctx.pagination.totalCount = count;
ctx.body = entities;
ctx.status = 200;
return next();
}
);
originalRouter.use(router.routes());
}

View file

@ -128,6 +128,7 @@ const identifiableEntityNames = [
'organization',
'organization-role',
'organization-scope',
'organization-invitation',
];
/**