Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
UseInterceptors,
} from '@nestjs/common';
import { FileInterceptor } from '@nestjs/platform-express';
import { ApiBody, ApiConsumes, ApiOAuth2, ApiOperation, ApiTags } from '@nestjs/swagger';
import { CurrentUser, Roles, RolesEnum } from '../../auth/decorators';
import { CrudController } from '../../core';
import { User } from '../user.entity';
import { CreateProfileDto } from './dto/create-profile.dto';
import { ProfileList } from './dto/profile-list.model';
import { Profile } from './profile.entity';
import { ProfileService } from './profile.service';
// UserModule -> SharedModule -> AuthModule -> UserModule, so
const ALLOWED_MIME_TYPES = ['image/gif', 'image/png', 'image/jpeg', 'image/bmp', 'image/webp'];
@ApiOAuth2(['read'])
@ApiTags('Profile', 'User')
@Controller('profile')
export class ProfileController extends CrudController {
constructor(private readonly profileService: ProfileService) {
super(profileService);
}
@ApiOperation({ summary: 'get CurrentUser Profile' })
@Get('myprofile')
async myProfile(@CurrentUser() user: User): Promise {
console.log('in myprofile', user.profileId);
if (user.profileId) {
// TODO: https://github.com/typeorm/typeorm/issues/1865
return this.profileService.findOne(user.profileId);
} else {
throw new NotFoundException('No Profile Found');
import { Body, Controller, HttpCode, HttpStatus, Post } from '@nestjs/common';
import { ApiOAuth2, ApiTags } from '@nestjs/swagger';
import { CurrentUser } from '../../auth/decorators';
import { EmailService } from '../../email';
import { User } from '../user.entity';
import { EmailDto } from './dto/email.dto';
@ApiOAuth2(['read'])
@ApiTags('Email', 'User')
@Controller('email')
export class EmailController {
constructor(private readonly emailService: EmailService) {}
// @ApiExcludeEndpoint()
@Post()
@HttpCode(HttpStatus.CREATED)
async sendEmail(@Body() email: EmailDto, @CurrentUser() user: User): Promise {
return this.emailService.sendMail({
to: user.email,
subject: email.title,
template: 'welcome', // The `.pug` extension is appended automatically.
context: {
// Data to be sent to PugJS template files.
title: email.title,
import { Controller, Get, Logger, Param } from '@nestjs/common';
import { ApiOAuth2, ApiOperation, ApiTags } from '@nestjs/swagger';
import { Roles, RolesEnum } from '../../auth/decorators';
import { KubernetesService } from './kubernetes.service';
@ApiOAuth2(['read'])
@ApiTags('Project', 'Kubernetes')
@Controller('kubernetes')
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();
}
import { Body, Controller, Delete, Get, HttpStatus, Param, ParseUUIDPipe, Post, Put, Query } from '@nestjs/common';
import { ApiExcludeEndpoint, ApiOAuth2, ApiOperation, ApiTags } from '@nestjs/swagger';
import { User } from '@ngx-starter-kit/models';
import { CurrentUser, Roles, RolesEnum } from '../../auth';
import { CrudController } from '../../core';
import { CreateNotificationDto } from './dto/create-notification.dto';
import { FindNotificationsDto } from './dto/find-notifications.dto';
import { FindOwnNotificationsDto } from './dto/find-own-notifications.dto';
import { NotificationList } from './dto/notification-list.model';
import { SendNotificationDto } from './dto/send-notification.dto';
import { UpdateNotificationDto } from './dto/update-notification.dto';
import { Notification } from './notification.entity';
import { NotificationService } from './notification.service';
@ApiOAuth2(['read'])
@ApiTags('Notifications')
@Controller('notifications')
export class NotificationController extends CrudController {
constructor(private readonly notificationService: NotificationService) {
super(notificationService);
}
@ApiOperation({ summary: 'Find all Notifications. Admins only' })
@ApiTags('Admin')
@Roles(RolesEnum.ADMIN)
@Get()
async findAll(@Query() filter: FindNotificationsDto): Promise {
// return super.findAll(filter);
return this.notificationService.findAll(filter);
}
} from '@nestjs/common';
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 { CacheInterceptor, Controller, Get, Logger, Param, UseInterceptors } from '@nestjs/common';
import { ApiOAuth2, ApiOperation, ApiTags } from '@nestjs/swagger';
import { Observable } from 'rxjs';
import { WeatherService } from './weather.service';
@ApiOAuth2(['read'])
@ApiTags('External', 'Weather')
@Controller('weather')
export class WeatherController {
private readonly logger = new Logger(WeatherController.name);
constructor(private readonly weatherService: WeatherService) {}
@ApiOperation({ summary: 'get weather by zipCode e.g., 91501' })
@UseInterceptors(CacheInterceptor)
@Get(':zip')
getWeather(@Param('zip') zip: string): Observable {
this.logger.log('weather zip', zip);
return this.weatherService.getWeatherByZip(zip);
}
@ApiOperation({ summary: 'get forecast by zipCode e.g., 91501' })
@Get('forecast/:zip')
import { Body, Controller, Get, HttpStatus, Param, Post, Put } from '@nestjs/common';
import { ApiOAuth2, ApiOperation, ApiTags } from '@nestjs/swagger';
import { Observable } from 'rxjs';
import { Roles, RolesEnum } from '../../auth';
import { CrudController } from '../../core';
import { Cluster } from './cluster.entity';
import { ClusterService } from './cluster.service';
import { CreateClusterDto } from './dto/create-cluster.dto';
import { UpdateClusterDto } from './dto/update-cluster.dto';
@ApiOAuth2(['read'])
@ApiTags('Project', 'Cluster', 'Admin')
@Roles(RolesEnum.ADMIN)
@Controller('cluster')
export class ClusterController extends CrudController {
constructor(private readonly clusterService: ClusterService) {
super(clusterService);
}
@Roles(RolesEnum.USER)
@ApiOperation({ summary: 'Get kubernetes cluster names' })
@Get('clusterNames')
getClusterNames(): Observable {
return this.clusterService.getClusterNames();
}
@ApiOperation({ summary: 'Find by Name' })
import { Body, Controller, Param, Post, Put } from '@nestjs/common';
import { ApiOAuth2, ApiOperation, ApiTags } from '@nestjs/swagger';
import { CrudController } from '../core';
import { CreateUserDto } from './dto/create-user.dto';
import { UpdateUserDto } from './dto/update-user.dto';
import { User } from './user.entity';
import { UserService } from './user.service';
@ApiOAuth2(['read'])
@ApiTags('User')
@Controller()
export class UserController extends CrudController {
constructor(private readonly userService: UserService) {
super(userService);
}
@ApiOperation({ summary: 'Create new record' })
@Post()
async create(@Body() entity: CreateUserDto): Promise {
return super.create(entity);
}
@ApiOperation({ summary: 'Update an existing record' })
@Put(':id')
async update(@Param('id') id: string, @Body() entity: UpdateUserDto): Promise {
import { Body, Controller, Delete, Get, HttpStatus, Param, Post, Put, Query } from '@nestjs/common';
import { ApiOAuth2, ApiOperation, ApiTags } from '@nestjs/swagger';
import { User } from '@ngx-starter-kit/models';
import { CurrentUser, Roles, RolesEnum } from '../../auth/decorators';
import { CrudController } from '../../core';
import { CreateSubscriptionDto } from './dto/create-subscription.dto';
import { FindOwnSubscriptionsDto } from './dto/find-own-subscriptions.dto';
import { FindSubscriptionsDto } from './dto/find-subscriptions.dto';
import { SubscriptionList } from './dto/subscription-list.model';
import { UpdateSubscriptionDto } from './dto/update-subscription.dto';
import { Subscription } from './subscription.entity';
import { SubscriptionService } from './subscription.service';
@ApiOAuth2(['read'])
@ApiTags('Subscription')
@Controller('subscription')
export class SubscriptionController extends CrudController {
constructor(private readonly subscriptionService: SubscriptionService) {
super(subscriptionService);
}
@ApiOperation({ summary: 'Find all Subscriptions. Admins only' })
@ApiTags('Admin')
@Roles(RolesEnum.ADMIN)
@Get()
async findAll(@Query() filter: FindSubscriptionsDto): Promise {
return this.subscriptionService.findAll(filter);
}
@ApiOperation({ summary: 'find all user Subscriptions' })