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

feat(core): get and delete org invitation by id

This commit is contained in:
Gao Sun 2024-01-15 08:26:25 +08:00
parent f9750ace90
commit e7fe20d32f
No known key found for this signature in database
GPG key ID: 13EBE123E4773688
2 changed files with 49 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());
}