-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
389 additions
and
382 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,106 +1,106 @@ | ||
import { | ||
Controller, | ||
Get, | ||
Param, | ||
UseGuards, | ||
Body, | ||
Post, | ||
Put, | ||
Patch, | ||
Controller, | ||
Get, | ||
Param, | ||
UseGuards, | ||
Body, | ||
Post, | ||
Put, | ||
Patch, | ||
} from '@nestjs/common'; | ||
import { AppsService } from './apps.service'; | ||
import { AuthGuard } from '../guards/auth.guard'; | ||
import { Delete } from '@nestjs/common'; | ||
|
||
// TODO: create a centralised interface file? | ||
interface CreateAppDto { | ||
name: string; | ||
description?: string; | ||
name: string; | ||
description?: string; | ||
} | ||
|
||
@Controller('apps') | ||
@UseGuards(AuthGuard) | ||
export class AppsController { | ||
constructor(private readonly appsService: AppsService) {} | ||
constructor(private readonly appsService: AppsService) { } | ||
|
||
@Get(':userAddress') | ||
async getUserApps(@Param('userAddress') userAddress: string) { | ||
// @note: This action fetches apps by userAddress; | ||
return this.appsService.getAppsByUser(userAddress); | ||
} | ||
@Get(':userAddress') | ||
async getUserApps(@Param('userAddress') userAddress: string) { | ||
// @note: This action fetches apps by userAddress; | ||
return this.appsService.getAppsByUser(userAddress); | ||
} | ||
|
||
@Post(':userAddress') | ||
async createApp( | ||
@Param('userAddress') userAddress: string, | ||
@Body() createAppDto: CreateAppDto, | ||
) { | ||
// @note: This action creates app for given userAddress; | ||
const { name, description } = createAppDto; | ||
return this.appsService.createApp(userAddress, name, description); | ||
} | ||
@Post(':userAddress') | ||
async createApp( | ||
@Param('userAddress') userAddress: string, | ||
@Body() createAppDto: CreateAppDto, | ||
) { | ||
// @note: This action creates app for given userAddress; | ||
const { name, description } = createAppDto; | ||
return this.appsService.createApp(userAddress, name, description); | ||
} | ||
|
||
@Delete(':appId') | ||
async deleteApp(@Param('appId') appId: string) { | ||
// @note: This action deletes app for given appId; | ||
return this.appsService.deleteApp(appId); | ||
} | ||
@Delete(':appId') | ||
async deleteApp(@Param('appId') appId: string) { | ||
// @note: This action deletes app for given appId; | ||
return this.appsService.deleteApp(appId); | ||
} | ||
|
||
@Patch(':appId') | ||
async updateApp(@Param('appId') appId: string, @Body() updateAppDto: any) { | ||
// @note: This action updates app for given appId; | ||
return this.appsService.updateApp(appId, updateAppDto); | ||
} | ||
@Patch(':appId') | ||
async updateApp(@Param('appId') appId: string, @Body() updateAppDto: any) { | ||
// @note: This action updates app for given appId; | ||
return this.appsService.updateApp(appId, updateAppDto); | ||
} | ||
|
||
@Post(':appId/rule') | ||
async createAppRule( | ||
@Param('appId') appId: string, | ||
@Body() | ||
createAppRuleDto: { | ||
ruleName: string; | ||
data: string[]; | ||
}, | ||
) { | ||
// @note: This action creates app rule given appId; | ||
return this.appsService.createAppRule(appId, createAppRuleDto); | ||
} | ||
@Post(':appId/rule') | ||
async createAppRule( | ||
@Param('appId') appId: string, | ||
@Body() | ||
createAppRuleDto: { | ||
ruleName: string; | ||
data: string[]; | ||
}, | ||
) { | ||
// @note: This action creates app rule given appId; | ||
return this.appsService.createAppRule(appId, createAppRuleDto.ruleName, createAppRuleDto.data); | ||
} | ||
|
||
@Patch(':appId/rule/:ruleName') | ||
async updateAppRule( | ||
@Param('appId') appId: string, | ||
@Param('ruleName') ruleName: string, | ||
@Body() updateAppRuleDto: string[], | ||
) { | ||
// @note: This action updates app rule for given appId and ruleName; | ||
return this.appsService.updateAppRule(appId, ruleName, updateAppRuleDto); | ||
} | ||
@Patch(':appId/rule/:ruleName') | ||
async updateAppRule( | ||
@Param('appId') appId: string, | ||
@Param('ruleName') ruleName: string, | ||
@Body() updateAppRuleDto: string[], | ||
) { | ||
// @note: This action updates app rule for given appId and ruleName; | ||
return this.appsService.updateAppRule(appId, ruleName, updateAppRuleDto); | ||
} | ||
|
||
@Delete(':appId/rule/:ruleName') | ||
async deleteAppRule( | ||
@Param('appId') appId: string, | ||
@Param('ruleName') ruleName: string, | ||
) { | ||
// @note: This action deletes app rule for given appId and ruleName; | ||
return this.appsService.deleteAppRule(appId, ruleName); | ||
} | ||
@Delete(':appId/rule/:ruleName') | ||
async deleteAppRule( | ||
@Param('appId') appId: string, | ||
@Param('ruleName') ruleName: string, | ||
) { | ||
// @note: This action deletes app rule for given appId and ruleName; | ||
return this.appsService.deleteAppRule(appId, ruleName); | ||
} | ||
|
||
@Patch(':appId/rules') | ||
async batchUpdateAppRules( | ||
@Param('appId') appId: string, | ||
@Body() updateRulesDto: { ruleName: string; data: string[] }, | ||
) { | ||
// @note: This action updates app rules in bulk for given appId; | ||
return this.appsService.batchUpdateAppRules(appId, updateRulesDto); | ||
} | ||
@Patch(':appId/rules') | ||
async batchUpdateAppRules( | ||
@Param('appId') appId: string, | ||
@Body() updateRulesDto: { ruleName: string; data: string[] }, | ||
) { | ||
// @note: This action updates app rules in bulk for given appId; | ||
return this.appsService.batchUpdateAppRules(appId, updateRulesDto.ruleName, updateRulesDto.data); | ||
} | ||
|
||
@Put(':appId/secret') | ||
async updateAppSecret(@Param('appId') appId: string) { | ||
// @note: This action updates app secret for given appId; | ||
return this.appsService.updateSecretKeyRule(appId, 'generate'); | ||
} | ||
@Put(':appId/secret') | ||
async updateAppSecret(@Param('appId') appId: string) { | ||
// @note: This action updates app secret for given appId; | ||
return this.appsService.updateSecretKeyRule(appId, 'generate'); | ||
} | ||
|
||
@Delete(':appId/secret') | ||
async deleteAppSecret(@Param('appId') appId: string) { | ||
// @note: This action deletes app secret for given appId; | ||
return this.appsService.updateSecretKeyRule(appId, 'delete'); | ||
} | ||
@Delete(':appId/secret') | ||
async deleteAppSecret(@Param('appId') appId: string) { | ||
// @note: This action deletes app secret for given appId; | ||
return this.appsService.updateSecretKeyRule(appId, 'delete'); | ||
} | ||
} |
Oops, something went wrong.