11import { StatusCodes } from 'http-status-codes' ;
22
3- import { fastifyCors } from '@fastify/cors' ;
43import { FastifyPluginAsyncTypebox } from '@fastify/type-provider-typebox' ;
54
65import { resolveDependency } from '../../di/utils' ;
@@ -14,23 +13,16 @@ import { ItemMembershipService } from './membership.service';
1413import MembershipRequestAPI from './plugins/MembershipRequest/membershipRequest.controller' ;
1514import { membershipWsHooks } from './ws/hooks' ;
1615
17- const ROUTES_PREFIX = '/item-memberships' ;
18-
1916const 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
0 commit comments