1- import { CacheKey , CacheTTL } from '@nestjs/cache-manager' ;
1+ import { CacheTTL } from '@nestjs/cache-manager' ;
22import {
33 Body ,
44 ConflictException ,
@@ -52,7 +52,7 @@ export class NamespaceController {
5252 const { key, ns } = createDto ;
5353
5454 if ( key ) {
55- const namespace = await this . namespaceService . getByKey ( key ) ;
55+ const namespace = await this . namespaceService . get ( key ) ;
5656 if ( namespace ) {
5757 throw new ConflictException ( {
5858 code : ErrorCodes . NAMESPACE_ALREADY_EXISTS ,
@@ -68,7 +68,7 @@ export class NamespaceController {
6868 }
6969
7070 if ( ns ) {
71- const parent = await this . namespaceService . getByKey ( ns ) ;
71+ const parent = await this . namespaceService . get ( ns ) ;
7272 if ( ! parent ) {
7373 throw new NotFoundException ( {
7474 code : ErrorCodes . NAMESPACE_NOT_FOUND ,
@@ -114,27 +114,27 @@ export class NamespaceController {
114114 }
115115
116116 /**
117- * Find namespace by id or key
117+ * Find namespace by key
118118 */
119119 @ApiOperation ( { operationId : 'getNamespace' } )
120120 @ApiOkResponse ( {
121- description : 'The namespace with expected id or key.' ,
121+ description : 'The namespace with expected key.' ,
122122 type : Namespace ,
123123 } )
124124 @ApiParam ( {
125- name : 'namespaceIdOrKey ' ,
125+ name : 'key ' ,
126126 type : 'string' ,
127- description : 'Namespace id or key, if key should encodeURIComponent' ,
127+ description : 'Namespace key, key should encodeURIComponent' ,
128128 } )
129129 @UseInterceptors ( SetCacheInterceptor )
130130 @CacheTTL ( 24 * 3600 )
131- @Get ( ':namespaceIdOrKey ' )
132- async get ( @Param ( 'namespaceIdOrKey ' ) namespaceIdOrKey : string ) : Promise < NamespaceDocument > {
133- const namespace = await this . namespaceService . get ( namespaceIdOrKey ) ;
131+ @Get ( ':key ' )
132+ async get ( @Param ( 'key ' ) key : string ) : Promise < NamespaceDocument > {
133+ const namespace = await this . namespaceService . get ( key ) ;
134134 if ( ! namespace ) {
135135 throw new NotFoundException ( {
136136 code : ErrorCodes . NAMESPACE_NOT_FOUND ,
137- message : `Namespace ${ namespaceIdOrKey } not found.` ,
137+ message : `Namespace ${ key } not found.` ,
138138 } ) ;
139139 }
140140 return namespace ;
@@ -149,17 +149,16 @@ export class NamespaceController {
149149 type : Namespace ,
150150 } )
151151 @UseInterceptors ( UnsetCacheInterceptor )
152- @CacheKey ( '/namespaces/:id,/namespaces/:key' )
153- @Patch ( ':namespaceIdOrKey' )
152+ @Patch ( ':key' )
154153 async update (
155- @Param ( 'namespaceIdOrKey ' ) namespaceIdOrKey : string ,
154+ @Param ( 'key ' ) key : string ,
156155 @Body ( ) updateDto : UpdateNamespaceDto
157156 ) : Promise < NamespaceDocument > {
158- const namespace = await this . namespaceService . update ( namespaceIdOrKey , updateDto ) ;
157+ const namespace = await this . namespaceService . update ( key , updateDto ) ;
159158 if ( ! namespace ) {
160159 throw new NotFoundException ( {
161160 code : ErrorCodes . NAMESPACE_NOT_FOUND ,
162- message : `Namespace ${ namespaceIdOrKey } not found.` ,
161+ message : `Namespace ${ key } not found.` ,
163162 } ) ;
164163 }
165164 return namespace ;
@@ -172,8 +171,8 @@ export class NamespaceController {
172171 @ApiNoContentResponse ( { description : 'No content.' } )
173172 @HttpCode ( HttpStatus . NO_CONTENT )
174173 @UseInterceptors ( UnsetCacheInterceptor )
175- @Delete ( ':namespaceId ' )
176- async delete ( @Param ( 'namespaceId ' ) namespaceId : string ) : Promise < void > {
177- await this . namespaceService . delete ( namespaceId ) ;
174+ @Delete ( ':key ' )
175+ async delete ( @Param ( 'key ' ) key : string ) : Promise < void > {
176+ await this . namespaceService . delete ( key ) ;
178177 }
179178}
0 commit comments