Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@Delete("/")
@Status(204)
@Authenticated({role: "admin"})
@Security("global_auth", "read:global")
@Security("calendar_auth", "write:calendar", "read:calendar")
public remove(
@BodyParams("id")
@Required()
id: string
): void {
return undefined;
}
@Delete("/token")
@Status(204)
@OAuth({role: "admin", scopes: ["write:calendar", "read:calendar"]})
public removeWithToken(@BodyParams("id") @Required() id: string): void {
return undefined;
}
/**
*
* @param request
* @param auth
* @returns {{user: (number|any|string)}}
*/
@Get("/middleware")
@Use(CalendarCtrl.middleware)
public getWithMiddleware(@Request() request: any, @HeaderParams("authorization") auth: string): any {
*
* @param event
* @returns {null}
*/
@Post("/list")
@Authenticated({role: "admin"})
@Returns(200, {use: EventModel, collection: Array})
update(@BodyParams("event", EventModel) event: EventModel[]): EventModel[] {
return event;
}
/**
*
* @returns {null}
*/
@Delete("/:id")
remove(): Promise | void {
return Promise.resolve(null);
}
/**
*
* @returns {null}
*/
@Get("/status")
byStatus(@QueryParams("status", String) status: string[]): Promise | void {
return Promise.resolve(status);
}
/**
*
* @returns {null}
*/
@Put("/")
@Returns(CalendarModel)
public save(
@BodyParams("name")
@Required()
name: string
): CalendarModel {
const model = new CalendarModel();
model.id = "2";
model.name = "test";
return model;
}
@Delete("/")
@Status(204)
@Authenticated({role: "admin"})
@Security("global_auth", "read:global")
@Security("calendar_auth", "write:calendar", "read:calendar")
public remove(
@BodyParams("id")
@Required()
id: string
): void {
return undefined;
}
@Delete("/token")
@Status(204)
@OAuth({role: "admin", scopes: ["write:calendar", "read:calendar"]})
@Put("/")
@Status(201)
@Returns(Calendar)
save(@BodyParams() calendar: CreateCalendar): Promise {
return this.calendarsService.create(calendar);
}
@Post("/:id")
@Returns(Calendar)
async update(@PathParams("id") @Required() id: string,
@BodyParams() @Required() calendar: CreateCalendar): Promise {
return this.calendarsService.update({id, ...calendar});
}
@Delete("/")
@Status(204)
async remove(@BodyParams("id") @Required() id: string): Promise {
await this.calendarsService.remove(id);
}
@Get("/")
@ReturnsArray(Calendar)
async getAllCalendars() {
return this.calendarsService.query();
}
}
@Post("/:id")
async update(@Required() @PathParams("calendarId") calendarId: string,
@PathParams("id") id: string,
@BodyParams("startDate") startDate: string,
@BodyParams("endDate") endDate: string,
@BodyParams("name") name: string): Promise {
const event = await this.get(calendarId, id);
event.name = name;
event.startDate = name;
event.endDate = name;
return event;
}
@Delete("/:id")
@Authenticated()
@Status(204)
async remove(@Required() @PathParams("calendarId") calendarId: string,
@PathParams("id") id: string): Promise {
this.events = this.events.filter(event => event.id === id && event.calendarId === calendarId);
}
@Get("/")
async getEvents(@Required() @PathParams("calendarId") calendarId: string): Promise {
return this.events.filter(event => event.calendarId === calendarId);
}
}
@Status(200, {description: "Success", type: Calendar})
async update(@PathParams("id") @Required() id: string,
@BodyParams() calendar: Calendar): Promise {
calendar._id = id;
return this.calendarsService.save
(calendar);
}
/**
*
* @param id
* @returns {{id: string, name: string}}
*/
@Delete("/:id")
@Summary("Remove a calendar.")
@Status(204, {description: "No content"})
async remove(@PathParams("id") id: string): Promise {
await this.calendarsService.remove(id);
}
@Delete("/")
@Summary("Remove all calendars.")
@Status(204, {description: "No content"})
async clear(@PathParams("id") id: string): Promise {
await this.calendarsService.clear();
}
/**
*
* @returns {Promise}
@PathParams("id") id: string,
@BodyParams() calendarEvent: CalendarEvent): Promise {
return this
.calendarEventsService
.find(id)
.then(() => this.calendarEventsService.save(calendarEvent))
.catch((err) => {
throw new NotFound("Calendar id not found");
});
}
/**
*
*/
@Delete("/:id")
@UseBefore(CheckCalendarIdMiddleware)
@Summary("Remove an event")
@Status(204, {description: "No content"})
async remove(@Description("The calendar id of the event")
@Required() @PathParams("calendarId") calendarId: string,
@Description("The event id")
@PathParams("id") id: string): Promise {
return this.calendarEventsService.remove(id);
}
@Get("/")
@Summary("Get all events for a calendar")
@Status(200, {description: "Success"})
async getEvents(@Description("The calendar id of the event")
@Required() @PathParams("calendarId") calendarId: string): Promise {
return this.calendarEventsService.query(calendarId);
* @param id
* @param name
* @returns {Promise}
*/
@Post("/:id")
async update(@PathParams("id") @Required() id: string,
@BodyParams("name") @Required() name: string): Promise {
return this.calendarsService.update({id, name});
}
/**
*
* @param id
* @returns {{id: string, name: string}}
*/
@Delete("/")
@Authenticated()
@Status(204)
async remove(@BodyParams("id") @Required() id: string): Promise {
this.calendarsService.remove(id);
}
@Get("/")
@Authenticated()
async getAllCalendars(): Promise {
return this.calendarsService.query();
}
}
* @param id
* @param name
* @returns {Promise}
*/
@Post("/:id")
async update(@PathParams("id") @Required() id: string,
@BodyParams("name") @Required() name: string): Promise {
return this.calendarsService.update({id, name});
}
/**
*
* @param id
* @returns {{id: string, name: string}}
*/
@Delete("/")
@Status(204)
async remove(@BodyParams("id") @Required() id: string): Promise {
this.calendarsService.remove(id);
}
@Get("/")
async getAllCalendars(): Promise {
return this.calendarsService.query();
}
}
(calendar);
}
/**
*
* @param id
* @returns {{id: string, name: string}}
*/
@Delete("/:id")
@Summary("Remove a calendar.")
@Status(204, {description: "No content"})
async remove(@PathParams("id") id: string): Promise {
await this.calendarsService.remove(id);
}
@Delete("/")
@Summary("Remove all calendars.")
@Status(204, {description: "No content"})
async clear(@PathParams("id") id: string): Promise {
await this.calendarsService.clear();
}
/**
*
* @returns {Promise}
*/
@Get("/")
@Summary("Return all calendars")
@Status(200, {description: "Success", type: Calendar, collectionType: Array})
async getAllCalendars(): Promise {
return this.calendarsService.query();
}