Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import {Any, IgnoreProperty, JsonProperty, Property, PropertyType, Required} from "@tsed/common";
import {Description, Example, Title} from "@tsed/swagger";
export class Task {
@JsonProperty() public name: string = "";
@JsonProperty() public percent: number;
}
@Title("EventModel Title")
export class EventModel {
@Title("iD")
@Description("Description of event model id")
@Example("1FDCHZKH")
@JsonProperty()
public id: string;
@Required()
@Example("example1", "2017-10-15T17:05:58.106Z")
public startDate: Date;
@JsonProperty()
@Required()
// @Format("date")
public endDate: Date;
@JsonProperty("Name")
@Required()
public name: string;
import {Minimum, Required, Property} from "@tsed/common";
import {Example, Description} from "@tsed/swagger";
import {Column, Entity, PrimaryGeneratedColumn} from "typeorm";
@Entity()
export class User {
@Description('Database assigned id')
@PrimaryGeneratedColumn()
id: number;
@Description('User firstname')
@Column()
@Required()
firstName: string;
@Description('User lastname')
@Column()
@Required()
lastName: string;
@Description('User Age')
@Column()
@Minimum(18)
@Example(18)
age: number;
additional: string; // won't be serialized/deserialized by Ts.ED because @PropertyType or other Ts.ED decorator are missing
@Property()
additional2: string;
}
import {BaseController} from "../base/BaseController";
import {EventCtrl} from "./EventCtrl";
interface ICalendar {
id: string;
name: string;
}
/**
* Add @ControllerProvider annotation to declare your provide as Router controller. The first param is the global path for your controller.
* The others params is the children controllers.
*
* In this case, EventCtrl is a depedency of CalendarCtrl. All routes of EventCtrl will be mounted on the `/calendars` path.
*/
@Controller("/calendars", EventCtrl)
@Description("Controller description")
export class CalendarCtrl extends BaseController {
constructor(private tokenService: TokenService) {
super(tokenService);
}
/**
*
* @param request
* @param response
* @param next
*/
static middleware(request: any, response: Express.Response, next: Express.NextFunction) {
request["user"] = 1;
response.locals.id = "local-10909";
request.ctx.set("uid", "ctx-10909");
import {Property, Required} from "@tsed/common";
import {Description, Example, Title} from "@tsed/swagger";
export class CalendarModel {
@Title("iD")
@Description("Description of calendar model id")
@Example("example1", "Description example")
@Property()
public id: string;
@Property()
@Required()
public name: string;
}
@Property()
@Description("Last modification date")
dateUpdate: Date = new Date();
@Property()
@Description("Beginning date of the event")
dateStart: Date = new Date();
@Property()
@Required()
@Description("Ending date of the event")
dateEnd: Date = new Date();
@Property()
@Description("Description the event")
description: string;
}
calendarId: Ref;
@Property("name")
@Description("The name of the event")
name: string;
@Property()
@Description("Creation's date")
dateCreate: Date = new Date();
@Property()
@Description("Last modification date")
dateUpdate: Date = new Date();
@Property()
@Description("Beginning date of the event")
dateStart: Date = new Date();
@Property()
@Required()
@Description("Ending date of the event")
dateEnd: Date = new Date();
@Property()
@Description("Description the event")
description: string;
}
_id: string;
@Ref(Calendar)
@Description("Calendar ID")
calendarId: Ref;
@Property("name")
@Description("The name of the event")
name: string;
@Property()
@Description("Creation's date")
dateCreate: Date = new Date();
@Property()
@Description("Last modification date")
dateUpdate: Date = new Date();
@Property()
@Description("Beginning date of the event")
dateStart: Date = new Date();
@Property()
@Required()
@Description("Ending date of the event")
dateEnd: Date = new Date();
@Property()
@Description("Description the event")
description: string;
}
@Property()
@Description("Creation's date")
dateCreate: Date = new Date();
@Property()
@Description("Last modification date")
dateUpdate: Date = new Date();
@Property()
@Description("Beginning date of the event")
dateStart: Date = new Date();
@Property()
@Required()
@Description("Ending date of the event")
dateEnd: Date = new Date();
@Property()
@Description("Description the event")
description: string;
}
import {Minimum, Required, Property} from "@tsed/common";
import {Example, Description} from "@tsed/swagger";
import {Column, Entity, PrimaryGeneratedColumn} from "typeorm";
@Entity()
export class User {
@Description('Database assigned id')
@PrimaryGeneratedColumn()
id: number;
@Description('User firstname')
@Column()
@Required()
firstName: string;
@Description('User lastname')
@Column()
@Required()
lastName: string;
@Description('User Age')
@Column()
@Minimum(18)
import {Property, PropertyName, Required} from "@tsed/common";
import {Model, Ref} from "@tsed/mongoose";
import {Description} from "@tsed/swagger";
import {Calendar} from "../calendars/Calendar";
@Model()
export class CalendarEvent {
@PropertyName("id")
_id: string;
@Ref(Calendar)
@Description("Calendar ID")
calendarId: Ref;
@Property("name")
@Description("The name of the event")
name: string;
@Property()
@Description("Creation's date")
dateCreate: Date = new Date();
@Property()
@Description("Last modification date")
dateUpdate: Date = new Date();
@Property()
@Description("Beginning date of the event")
dateStart: Date = new Date();
@Property()
@Required()