Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export class NamedEntity implements Entity {
public id: number;
public name: string;
}
@Path('abstract')
export class AbstractEntityEndpoint {
@GET
public get(): NamedEntity {
return new NamedEntity();
}
}
@Path('secure')
@Security(['ROLE_1', 'ROLE_2'], 'access_token')
export class SecureEndpoint {
@GET
public get(): string {
return 'Access Granted';
}
@POST
@Security([], 'user_email')
public post(): string {
return 'Posted';
}
}
@Path('supersecure')
@Security('access_token')
@Security('user_email')
export class SecureEndpoint {
@GET
public get(): string {
return 'Access Granted';
}
@POST
@Security([], 'user_email')
public post(): string {
return 'Posted';
}
}
@Path('supersecure')
@Security('access_token')
@Security('user_email')
@Security()
export class SuperSecureEndpoint {
@GET
public get(): string {
return 'Access Granted';
}
}
@Path('response')
@swagger.Response(400, 'The request format was incorrect.')
@swagger.Response(500, 'There was an unexpected error.')
export class ResponseController {
@GET
public get(): string {
return '42';
}
@GET
public get(): string {
return 'Access Granted';
}
@POST
@Security([], 'user_email')
public post(): string {
return 'Posted';
}
}
@Path('supersecure')
@Security('access_token')
@Security('user_email')
@Security()
export class SuperSecureEndpoint {
@GET
public get(): string {
return 'Access Granted';
}
}
@Path('response')
@swagger.Response(400, 'The request format was incorrect.')
@swagger.Response(500, 'There was an unexpected error.')
export class ResponseController {
@GET
public get(): string {
return '42';
}
@Path(":shortcode/draft")
@Security([ROLE_USER, ROLE_ADMIN])
public async createDraftPolicy(@PathParam("shortcode") shortcode: string, request: CreatePolicyObject): Promise {
return this.termsController.createDraftPolicy(request.name, shortcode, request.text, request.url);
}
@POST
@Path(":shortcode/publish/:version")
@Security([ROLE_USER, ROLE_ADMIN])
public async publishDraftPolicy(@PathParam("shortcode") shortcode: string, @PathParam("version") version: string): Promise {
return this.termsController.publishPolicy(shortcode, version);
}
@PUT
@Path(":shortcode/:version")
@Security([ROLE_USER, ROLE_ADMIN])
public async updatePolicy(@PathParam("shortcode") shortcode: string, @PathParam("version") version: string, request: CreatePolicyObject): Promise {
return this.termsController.updatePolicy(request.name, shortcode, version, request.text, request.url);
}
}
@Inject
private accountController: AccountController;
@Context
private context: ServiceContext;
@POST
@Path("register")
public async register(request: OpenId): Promise {
return this.accountController.registerAccount(request);
}
@GET
@Path("")
@Security(ROLE_MSC_USER)
public async info(): Promise {
const user: IMSCUser = this.context.request.user;
return {user_id: user.userId};
}
@POST
@Path("logout")
@Security(ROLE_MSC_USER)
public async logout(): Promise {
await this.accountController.logout(this.context.request.user);
return {};
}
}
url: string;
}
/**
* Administrative API for configuring terms of service.
*/
@Path("/api/v1/dimension/admin/terms")
@AutoWired
export class AdminTermsService {
@Inject
private termsController: TermsController;
@GET
@Path("all")
@Security([ROLE_USER, ROLE_ADMIN])
public async getPolicies(): Promise {
return this.termsController.getPoliciesForAdmin();
}
@GET
@Path(":shortcode/:version")
@Security([ROLE_USER, ROLE_ADMIN])
public async getPolicy(@PathParam("shortcode") shortcode: string, @PathParam("version") version: string): Promise {
return this.termsController.getPolicyForAdmin(shortcode, version);
}
@POST
@Path(":shortcode/draft")
@Security([ROLE_USER, ROLE_ADMIN])
public async createDraftPolicy(@PathParam("shortcode") shortcode: string, request: CreatePolicyObject): Promise {
return this.termsController.createDraftPolicy(request.name, shortcode, request.text, request.url);
@Path("register")
public async register(request: OpenId): Promise {
return this.accountController.registerAccount(request);
}
@GET
@Path("")
@Security(ROLE_MSC_USER)
public async info(): Promise {
const user: IMSCUser = this.context.request.user;
return {user_id: user.userId};
}
@POST
@Path("logout")
@Security(ROLE_MSC_USER)
public async logout(): Promise {
await this.accountController.logout(this.context.request.user);
return {};
}
}
@Inject
private termsController: TermsController;
@Context
private context: ServiceContext;
@GET
@Path("")
public async getAllTerms(): Promise {
return this.termsController.getAvailableTerms();
}
@POST
@Path("")
@Security(ROLE_USER)
public async signTerms(request: SignTermsRequest): Promise {
await this.termsController.signTermsMatching(this.context.request.user, request.user_accepts);
return {};
}
}
@Path("all")
@Security([ROLE_USER, ROLE_ADMIN])
public async getPolicies(): Promise {
return this.termsController.getPoliciesForAdmin();
}
@GET
@Path(":shortcode/:version")
@Security([ROLE_USER, ROLE_ADMIN])
public async getPolicy(@PathParam("shortcode") shortcode: string, @PathParam("version") version: string): Promise {
return this.termsController.getPolicyForAdmin(shortcode, version);
}
@POST
@Path(":shortcode/draft")
@Security([ROLE_USER, ROLE_ADMIN])
public async createDraftPolicy(@PathParam("shortcode") shortcode: string, request: CreatePolicyObject): Promise {
return this.termsController.createDraftPolicy(request.name, shortcode, request.text, request.url);
}
@POST
@Path(":shortcode/publish/:version")
@Security([ROLE_USER, ROLE_ADMIN])
public async publishDraftPolicy(@PathParam("shortcode") shortcode: string, @PathParam("version") version: string): Promise {
return this.termsController.publishPolicy(shortcode, version);
}
@PUT
@Path(":shortcode/:version")
@Security([ROLE_USER, ROLE_ADMIN])
public async updatePolicy(@PathParam("shortcode") shortcode: string, @PathParam("version") version: string, request: CreatePolicyObject): Promise {
return this.termsController.updatePolicy(request.name, shortcode, version, request.text, request.url);
@AutoWired
export class AdminTermsService {
@Inject
private termsController: TermsController;
@GET
@Path("all")
@Security([ROLE_USER, ROLE_ADMIN])
public async getPolicies(): Promise {
return this.termsController.getPoliciesForAdmin();
}
@GET
@Path(":shortcode/:version")
@Security([ROLE_USER, ROLE_ADMIN])
public async getPolicy(@PathParam("shortcode") shortcode: string, @PathParam("version") version: string): Promise {
return this.termsController.getPolicyForAdmin(shortcode, version);
}
@POST
@Path(":shortcode/draft")
@Security([ROLE_USER, ROLE_ADMIN])
public async createDraftPolicy(@PathParam("shortcode") shortcode: string, request: CreatePolicyObject): Promise {
return this.termsController.createDraftPolicy(request.name, shortcode, request.text, request.url);
}
@POST
@Path(":shortcode/publish/:version")
@Security([ROLE_USER, ROLE_ADMIN])
public async publishDraftPolicy(@PathParam("shortcode") shortcode: string, @PathParam("version") version: string): Promise {
return this.termsController.publishPolicy(shortcode, version);