Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@ApiTags('Admin')
@Roles(RolesEnum.ADMIN)
@Get()
async findAll(@Query() filter: FindNotificationsDto): Promise {
// return super.findAll(filter);
return this.notificationService.findAll(filter);
}
@ApiOperation({ summary: "find user's and global Notifications" }) // tslint:disable-line
@Get('own')
async findOwn(@Query() filter: FindOwnNotificationsDto, @CurrentUser() user): Promise {
return this.notificationService.findOwn(filter, user);
}
@ApiOperation({ summary: 'Find by id. Admins only' })
@ApiTags('Admin')
@Roles(RolesEnum.ADMIN)
@Get(':id')
async findById(@Param('id', new ParseUUIDPipe({ version: '4' })) id: string): Promise {
return super.findById(id);
}
@ApiOperation({ summary: 'Create new record. Admins only' })
@ApiTags('Admin')
@Roles(RolesEnum.ADMIN)
@Post()
async create(@Body() entity: CreateNotificationDto): Promise {
return super.create(entity);
}
@ApiExcludeEndpoint()
@ApiTags('Admin')
super(projectService);
}
@ApiOperation({ summary: 'Find all Projects. Admins only' })
@ApiTags('Admin')
@Roles(RolesEnum.ADMIN)
@Get()
async findAll(@Query() filter: FindProjectsDto): Promise {
return this.projectService.findAll(filter);
}
@ApiOperation({
summary: 'Search all Projects. Admins only',
description: 'Ref: https://github.com/rjlopezdev/typeorm-express-query-builder',
})
@ApiTags('Admin')
@Roles(RolesEnum.ADMIN)
@Get('/search')
async searchAll(query: any): Promise {
return this.projectService.searchAll(query);
}
@ApiOperation({ summary: 'find all user Projects' })
@Get('/own')
async findOwn(@Query() filter: FindOwnProjectsDto, @CurrentUser() user: User, @Token() token): Promise {
// TODO use token to get groups and fetch all projects that belongs to user and user's group
return this.projectService.findOwn(filter, user);
}
// @ApiOperation({ summary: 'Find projects with any given groups or userId' })
// @Post('/search')
// async search(@Body() filter: SearchProjectDto): Promise {
export class KubernetesController {
readonly logger = new Logger(KubernetesController.name);
constructor(private readonly kubernetesService: KubernetesService) {}
// @ApiExcludeEndpoint()
@Roles(RolesEnum.ADMIN)
@ApiTags('Admin')
@ApiOperation({ summary: 'Refresh kubernetes clusters from database' })
@Get('refresh')
refreshClusters(): Promise {
return this.kubernetesService.refreshClusters();
}
@Roles(RolesEnum.ADMIN)
@ApiTags('Admin')
@ApiOperation({ summary: 'Get all namespaces in a cluster by cluster name' })
@Get(':cluster')
listNamespaces(@Param('cluster') cluster: string): Promise {
return this.kubernetesService.listNamespaces(cluster);
}
@ApiOperation({ summary: 'Find one namespace in a cluster by namespace name' })
@Get(':cluster/:namespace')
getNamespace(@Param('cluster') cluster: string, @Param('namespace') namespace: string): Promise {
return this.kubernetesService.getNamespace({ cluster, namespace });
}
@ApiOperation({ summary: 'Scrape all data in a cluster by namespace name' })
@Get('scrape/:cluster/:namespace')
scrape(@Param('cluster') cluster: string, @Param('namespace') namespace: string): Promise {
return this.kubernetesService.scrape({ cluster, namespace });
import { Controller } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
@ApiTags('core')
@Controller()
export class AdminController {}
@Crud({
model: {
type: Company,
},
dto,
serialize,
query: {
alwaysPaginate: true,
join: {
users: {},
projects: {},
},
},
})
@ApiTags('companies')
@Controller('companies')
export class CompaniesController {
constructor(public service: CompaniesService) {}
}
model: { type: Device },
serialize,
params: {
deviceKey: {
field: 'deviceKey',
type: 'uuid',
primary: true,
},
},
routes: {
deleteOneBase: {
returnDeleted: true,
},
},
})
@ApiTags('devices')
@Controller('/devices')
export class DevicesController {
constructor(public service: DevicesService) {}
}
import { ApiOAuth2, ApiOperation, ApiTags } from '@nestjs/swagger';
import { User } from '@ngx-starter-kit/models';
import { CurrentUser, Roles, RolesEnum, Token } from '../auth';
import { CrudController } from '../core';
import { CreateProjectDto } from './dto/create-project.dto';
import { FindOwnProjectsDto } from './dto/find-own-projects.dto';
import { FindProjectsDto } from './dto/find-projects.dto';
import { ProjectList } from './dto/project-list.model';
import { UpdateProjectDto } from './dto/update-project.dto';
import { KubeContext } from './interfaces/kube-context';
import { KubernetesService } from './kubernetes/kubernetes.service';
import { Project } from './project.entity';
import { ProjectService } from './project.service';
@ApiOAuth2(['read'])
@ApiTags('Project')
@Controller('project')
export class ProjectController extends CrudController {
private readonly logger = new Logger(ProjectController.name);
constructor(private readonly projectService: ProjectService, private readonly kservice: KubernetesService) {
super(projectService);
}
@ApiOperation({ summary: 'Find all Projects. Admins only' })
@ApiTags('Admin')
@Roles(RolesEnum.ADMIN)
@Get()
async findAll(@Query() filter: FindProjectsDto): Promise {
return this.projectService.findAll(filter);
}
import { Body, Controller, Get, Param, Post } from '@nestjs/common';
import {
ApiBearerAuth,
ApiOperation,
ApiResponse,
ApiTags,
} from '@nestjs/swagger';
import { CatsService } from './cats.service';
import { Cat } from './classes/cat.class';
import { CreateCatDto } from './dto/create-cat.dto';
@ApiBearerAuth()
@ApiTags('cats')
@Controller('cats')
export class CatsController {
constructor(private readonly catsService: CatsService) {}
@Post()
@ApiOperation({ summary: 'Create cat' })
@ApiResponse({ status: 403, description: 'Forbidden.' })
async create(@Body() createCatDto: CreateCatDto): Promise {
return this.catsService.create(createCatDto);
}
@Get(':id')
@ApiResponse({
status: 200,
description: 'The found record',
type: Cat,
import { Controller, Get, Header, Redirect, HttpStatus } from '@nestjs/common';
import { ApiOperation, ApiTags, ApiResponse } from '@nestjs/swagger';
import { ShieldsService } from './shields.service';
@Controller('api/shields')
@ApiTags('Shields')
export class ShieldsController {
constructor(private readonly shieldsService: ShieldsService) { }
@Get()
@Redirect('api/shields/achievements', HttpStatus.MOVED_PERMANENTLY)
@ApiOperation({ summary: 'Redirects to api/shields/achievements' })
@ApiResponse({ status: HttpStatus.MOVED_PERMANENTLY })
redirectToGetAchievementsShield() {
}
@Get('achievements')
@Header('Content-Type', 'image/svg+xml;charset=utf-8')
@Header('Pragma-directive', 'no-cache')
@Header('Cache-directive', 'no-cache')
@Header('Pragma', 'no-cache')
join: {
company: {
exclude: ['description'],
},
'company.projects': {
alias: 'pr',
exclude: ['description'],
},
profile: {
eager: true,
exclude: ['updatedAt'],
},
},
},
})
@ApiTags('users')
@Controller('/companies/:companyId/users')
export class UsersController implements CrudController {
constructor(public service: UsersService) {}
get base(): CrudController {
return this;
}
@Override('getManyBase')
getAll(@ParsedRequest() req: CrudRequest) {
return this.base.getManyBase(req);
}
}