Skip to content
This repository has been archived by the owner on Apr 19, 2023. It is now read-only.

Commit

Permalink
🐛 Move scopes endpoint to top
Browse files Browse the repository at this point in the history
  • Loading branch information
AnandChowdhary committed Nov 3, 2020
1 parent 43e8596 commit f883155
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 16 deletions.
10 changes: 10 additions & 0 deletions http/create-access-token.http
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@baseUrl = http://localhost:3000
@userId = 1

POST {{baseUrl}}/users/{{userId}}/access-tokens
content-type: application/json
Authorization: Bearer {{$dotenv HTTP_TEST_ACCESS_TOKEN}}

{
"scopes": ["user-1:read-info"]
}
6 changes: 6 additions & 0 deletions http/get-access-token-scopes.http
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@baseUrl = http://localhost:3000
@userId = 1

GET {{baseUrl}}/users/{{userId}}/access-tokens/scopes
content-type: application/json
Authorization: Bearer {{$dotenv HTTP_TEST_ACCESS_TOKEN}}
6 changes: 6 additions & 0 deletions http/get-access-tokens.http
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@baseUrl = http://localhost:3000
@userId = 1

GET {{baseUrl}}/users/{{userId}}/access-tokens
content-type: application/json
Authorization: Bearer {{$dotenv HTTP_TEST_ACCESS_TOKEN}}
6 changes: 6 additions & 0 deletions http/get-group.http
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@baseUrl = http://localhost:3000
@groupId = 1

GET {{baseUrl}}/groups/{{groupId}}
content-type: application/json
Authorization: Bearer {{$dotenv HTTP_TEST_ACCESS_TOKEN}}
16 changes: 8 additions & 8 deletions src/modules/access-tokens/access-tokens.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ export class AccessTokenController {
});
}

@Get('scopes')
@Scopes('user-{userId}:read-access-token-{id}')
async scopes(
@Param('userId', ParseIntPipe) userId: number,
): Promise<Record<string, string>> {
return this.accessTokensService.getAccessTokenScopes(userId);
}

@Get(':id')
@Scopes('user-{userId}:read-access-token-{id}')
async get(
Expand Down Expand Up @@ -93,12 +101,4 @@ export class AccessTokenController {
): Promise<Expose<accessTokens>> {
return this.accessTokensService.deleteAccessToken(userId, Number(id));
}

@Get('scopes')
@Scopes('user-{userId}:read-access-token-{id}')
async scopes(
@Param('userId', ParseIntPipe) userId: number,
): Promise<Record<string, string>> {
return this.accessTokensService.getAccessTokenScopes(userId);
}
}
16 changes: 8 additions & 8 deletions src/modules/api-keys/api-keys.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ export class ApiKeyController {
});
}

@Get('scopes')
@Scopes('group-{groupId}:write-api-key-*')
async scopes(
@Param('groupId', ParseIntPipe) groupId: number,
): Promise<Record<string, string>> {
return this.apiKeysService.getApiKeyScopes(groupId);
}

@Get(':id')
@Scopes('group-{groupId}:read-api-key-{id}')
async get(
Expand Down Expand Up @@ -93,12 +101,4 @@ export class ApiKeyController {
): Promise<Expose<apiKeys>> {
return this.apiKeysService.deleteApiKey(groupId, Number(id));
}

@Get('scopes')
@Scopes('group-{groupId}:write-api-key-*')
async scopes(
@Param('groupId', ParseIntPipe) groupId: number,
): Promise<Record<string, string>> {
return this.apiKeysService.getApiKeyScopes(groupId);
}
}

0 comments on commit f883155

Please sign in to comment.