Skip to content

Commit

Permalink
save progress
Browse files Browse the repository at this point in the history
  • Loading branch information
wtfsayo committed May 18, 2024
1 parent 25fd865 commit 8638937
Show file tree
Hide file tree
Showing 2 changed files with 389 additions and 382 deletions.
164 changes: 82 additions & 82 deletions web-portal/backend/src/apps/apps.controller.ts
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');
}
}
Loading

0 comments on commit 8638937

Please sign in to comment.