Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
color: "blue",
id: 1,
label: "first widget",
},
];
@Route("widgets")
export class WidgetsController {
@Get()
@Tags("Widgets")
public async GetWidgets(): Promise {
return widgets;
}
@Get("{widgetId}")
@Tags("Widgets")
public async GetWidget(widgetId: number): Promise {
const widget = widgets.find((w) => w.id === widgetId);
if (!widget) {
throw new ServerError(`no widget found with id ${widgetId}`);
}
return widget;
}
}