Skip to content

Commit 7f3cdf4

Browse files
kimpyphilia
authored andcommitted
feat: move membership endpoint
1 parent 0c0eb5a commit 7f3cdf4

5 files changed

Lines changed: 7 additions & 15 deletions

File tree

src/app.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ export default async function (instance: FastifyInstance): Promise<void> {
5959
})
6060
.register(fp(MemberServiceApi))
6161
.register(fp(ItemServiceApi))
62-
.register(fp(ItemMembershipServiceApi))
6362
.register(tagPlugin);
6463
});
6564
}

src/services/item/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
} from '../../utils/config';
1313
import chatController from '../chat/chatMessage.controller';
1414
import graaspItemLogin from '../itemLogin/itemLogin.controller';
15+
import itemMembershipsPlugin from '../itemMembership/membership.controller';
1516
import itemController from './item.controller';
1617
import actionItemPlugin from './plugins/action/itemAction.controller';
1718
import graaspApps from './plugins/app/app.controller';
@@ -71,6 +72,8 @@ const plugin: FastifyPluginAsync = async (fastify) => {
7172

7273
fastify.register(graaspItemPublish);
7374

75+
fastify.register(itemMembershipsPlugin);
76+
7477
fastify.register(graaspShortcutPlugin);
7578

7679
fastify.register(thumbnailsPlugin);

src/services/itemMembership/membership.controller.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { StatusCodes } from 'http-status-codes';
22

3-
import { fastifyCors } from '@fastify/cors';
43
import { FastifyPluginAsyncTypebox } from '@fastify/type-provider-typebox';
54

65
import { resolveDependency } from '../../di/utils';
@@ -14,23 +13,16 @@ import { ItemMembershipService } from './membership.service';
1413
import MembershipRequestAPI from './plugins/MembershipRequest/membershipRequest.controller';
1514
import { membershipWsHooks } from './ws/hooks';
1615

17-
const ROUTES_PREFIX = '/item-memberships';
18-
1916
const plugin: FastifyPluginAsyncTypebox = async (fastify) => {
2017
const itemMembershipService = resolveDependency(ItemMembershipService);
2118

2219
fastify.register(MembershipRequestAPI, {
23-
prefix: '/items/:itemId/memberships/requests',
20+
prefix: '/:itemId/memberships/requests',
2421
});
2522

2623
// routes
2724
fastify.register(
2825
async function (fastify: FastifyInstanceTypebox) {
29-
// add CORS support
30-
if (fastify.corsPluginOptions) {
31-
fastify.register(fastifyCors, fastify.corsPluginOptions);
32-
}
33-
3426
fastify.register(membershipWsHooks);
3527

3628
// get many item's memberships
@@ -94,7 +86,7 @@ const plugin: FastifyPluginAsyncTypebox = async (fastify) => {
9486
},
9587
);
9688
},
97-
{ prefix: ROUTES_PREFIX },
89+
{ prefix: '/:itemId/memberships' },
9890
);
9991
};
10092

src/services/itemMembership/membership.schemas.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ export const updateOne = {
9797

9898
params: customType.StrictObject({
9999
id: customType.UUID(),
100+
itemId: customType.UUID(),
100101
}),
101102
body: customType.StrictObject({
102103
permission: customType.EnumString(Object.values(PermissionLevel)),
@@ -116,6 +117,7 @@ export const deleteOne = {
116117

117118
params: customType.StrictObject({
118119
id: customType.UUID(),
120+
itemId: customType.UUID(),
119121
}),
120122
querystring: customType.StrictObject({
121123
purgeBelow: Type.Optional(Type.Boolean()),

src/services/itemMembership/plugins/MembershipRequest/membershipRequest.controller.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,6 @@ const plugin: FastifyPluginAsyncTypebox = async (fastify) => {
3434
const itemLoginService = resolveDependency(ItemLoginService);
3535
const authorizationService = resolveDependency(AuthorizationService);
3636

37-
if (fastify.corsPluginOptions) {
38-
await fastify.register(fastifyCors, fastify.corsPluginOptions);
39-
}
40-
4137
fastify.get(
4238
'/',
4339
{

0 commit comments

Comments
 (0)