first commit
This commit is contained in:
7
aws_sigma_service/common/src/dto/cpu-info.dto.ts
Normal file
7
aws_sigma_service/common/src/dto/cpu-info.dto.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import { IsNotEmpty, IsNumber } from "class-validator";
|
||||
|
||||
export class CpuInfoDto {
|
||||
@IsNumber()
|
||||
@IsNotEmpty()
|
||||
usage!: number;
|
||||
}
|
||||
36
aws_sigma_service/common/src/dto/create-function.dto.ts
Normal file
36
aws_sigma_service/common/src/dto/create-function.dto.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import {
|
||||
IsArray,
|
||||
IsNotEmpty,
|
||||
IsOptional,
|
||||
IsString,
|
||||
IsUppercase,
|
||||
Matches,
|
||||
} from "class-validator";
|
||||
|
||||
export class CreateFunctionDto {
|
||||
@IsNotEmpty()
|
||||
@IsString()
|
||||
name!: string;
|
||||
|
||||
@IsNotEmpty()
|
||||
@IsString()
|
||||
@Matches(
|
||||
/^\/(?:$|(?:[A-Za-z0-9._~-]+|:[A-Za-z0-9_]+)(?:\/(?:[A-Za-z0-9._~-]+|:[A-Za-z0-9_]+))*)$/,
|
||||
{
|
||||
message:
|
||||
"path must be a valid endpoint path (e.g. / or /hello/world/:id)",
|
||||
}
|
||||
)
|
||||
path!: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsNotEmpty()
|
||||
@IsString()
|
||||
code?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsArray()
|
||||
@IsString({ each: true })
|
||||
@IsUppercase({ each: true })
|
||||
methods?: string[];
|
||||
}
|
||||
26
aws_sigma_service/common/src/dto/create-project.dto.ts
Normal file
26
aws_sigma_service/common/src/dto/create-project.dto.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import {
|
||||
IsNotEmpty,
|
||||
IsNumber,
|
||||
IsOptional,
|
||||
IsString,
|
||||
Min,
|
||||
} from "class-validator";
|
||||
|
||||
export class CreateProjectDto {
|
||||
@IsNotEmpty()
|
||||
@IsString()
|
||||
name!: string;
|
||||
|
||||
@IsNotEmpty()
|
||||
@IsString()
|
||||
slug!: string;
|
||||
|
||||
@IsNotEmpty()
|
||||
@IsString()
|
||||
description!: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsNumber()
|
||||
@Min(1)
|
||||
cpuTimeQuotaMsPerMinute?: number;
|
||||
}
|
||||
11
aws_sigma_service/common/src/dto/dto.ts
Normal file
11
aws_sigma_service/common/src/dto/dto.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
export * from "./cpu-info.dto.js";
|
||||
export * from "./create-function.dto.js";
|
||||
export * from "./create-project.dto.js";
|
||||
export * from "./function.dto.js";
|
||||
export * from "./project.dto.js";
|
||||
export * from "./query-project.dto.js";
|
||||
export * from "./register-user.dto.js";
|
||||
export * from "./update-function.dto.js";
|
||||
export * from "./update-project.dto.js";
|
||||
export * from "./update-user.dto.js";
|
||||
export * from "./user.dto.js";
|
||||
39
aws_sigma_service/common/src/dto/function.dto.ts
Normal file
39
aws_sigma_service/common/src/dto/function.dto.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import {
|
||||
IsArray,
|
||||
IsNotEmpty,
|
||||
IsNumber,
|
||||
IsOptional,
|
||||
IsString,
|
||||
} from "class-validator";
|
||||
|
||||
export class FunctionDto {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
_id!: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
name!: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
path!: string;
|
||||
|
||||
@IsArray()
|
||||
methods!: string[];
|
||||
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
code?: string;
|
||||
|
||||
@IsNumber()
|
||||
invocations!: number;
|
||||
|
||||
@IsNumber()
|
||||
errors!: number;
|
||||
|
||||
@IsArray()
|
||||
logs!: string[];
|
||||
|
||||
lastInvocation?: Date;
|
||||
}
|
||||
45
aws_sigma_service/common/src/dto/project.dto.ts
Normal file
45
aws_sigma_service/common/src/dto/project.dto.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
import { Type } from "class-transformer";
|
||||
import {
|
||||
IsArray,
|
||||
IsDateString,
|
||||
IsNotEmpty,
|
||||
IsNumber,
|
||||
IsOptional,
|
||||
IsString,
|
||||
ValidateNested,
|
||||
} from "class-validator";
|
||||
import { FunctionDto } from "./function.dto.js";
|
||||
|
||||
export class ProjectDto {
|
||||
@IsNotEmpty()
|
||||
_id!: string;
|
||||
|
||||
@IsNotEmpty()
|
||||
name!: string;
|
||||
|
||||
@IsNotEmpty()
|
||||
slug!: string;
|
||||
|
||||
@IsOptional()
|
||||
description?: string;
|
||||
|
||||
@IsNumber()
|
||||
cpuTimeQuotaMsPerMinute!: number;
|
||||
|
||||
@IsDateString()
|
||||
cpuTimeWindowStartedAt!: string;
|
||||
|
||||
@IsNumber()
|
||||
cpuTimeUsedMs!: number;
|
||||
|
||||
@IsNumber()
|
||||
functionsInvocationCount!: number;
|
||||
|
||||
@IsNumber()
|
||||
functionsErrorCount!: number;
|
||||
|
||||
@IsArray()
|
||||
@ValidateNested({ each: true })
|
||||
@Type(() => FunctionDto)
|
||||
functions!: FunctionDto[];
|
||||
}
|
||||
4
aws_sigma_service/common/src/dto/query-project.dto.ts
Normal file
4
aws_sigma_service/common/src/dto/query-project.dto.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
import { PartialType } from "@nestjs/mapped-types";
|
||||
import { ProjectDto } from "./project.dto.js";
|
||||
|
||||
export class QueryProjectDto extends PartialType(ProjectDto) {}
|
||||
11
aws_sigma_service/common/src/dto/register-user.dto.ts
Normal file
11
aws_sigma_service/common/src/dto/register-user.dto.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { IsNotEmpty, IsString, MinLength } from "class-validator";
|
||||
|
||||
export class RegisterUserDto {
|
||||
@IsNotEmpty()
|
||||
@IsString()
|
||||
username!: string;
|
||||
|
||||
@MinLength(8)
|
||||
@IsString()
|
||||
password!: string;
|
||||
}
|
||||
4
aws_sigma_service/common/src/dto/update-function.dto.ts
Normal file
4
aws_sigma_service/common/src/dto/update-function.dto.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
import { PartialType } from "@nestjs/mapped-types";
|
||||
import { CreateFunctionDto } from "./create-function.dto.js";
|
||||
|
||||
export class UpdateFunctionDto extends PartialType(CreateFunctionDto) {}
|
||||
4
aws_sigma_service/common/src/dto/update-project.dto.ts
Normal file
4
aws_sigma_service/common/src/dto/update-project.dto.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
import { PartialType } from "@nestjs/mapped-types";
|
||||
import { CreateProjectDto } from "./create-project.dto.js";
|
||||
|
||||
export class UpdateProjectDto extends PartialType(CreateProjectDto) {}
|
||||
4
aws_sigma_service/common/src/dto/update-user.dto.ts
Normal file
4
aws_sigma_service/common/src/dto/update-user.dto.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
import { PickType } from "@nestjs/mapped-types";
|
||||
import { RegisterUserDto } from "./register-user.dto.js";
|
||||
|
||||
export class UpdateUserDto extends PickType(RegisterUserDto, ["password"]) {}
|
||||
7
aws_sigma_service/common/src/dto/user.dto.ts
Normal file
7
aws_sigma_service/common/src/dto/user.dto.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import { IsNotEmpty, IsString } from "class-validator";
|
||||
|
||||
export class UserDto {
|
||||
@IsNotEmpty()
|
||||
@IsString()
|
||||
username!: string;
|
||||
}
|
||||
1
aws_sigma_service/common/src/lib.ts
Normal file
1
aws_sigma_service/common/src/lib.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from "./dto/dto.js";
|
||||
Reference in New Issue
Block a user