with-rest-controller.ts 613 B

123456789101112131415161718192021222324252627
  1. import { Controller, Get } from '@nestjs/common';
  2. import { Permission } from '@vendure/common/lib/generated-shop-types';
  3. import { Allow, InternalServerError, VendurePlugin } from '@vendure/core';
  4. @Controller('test')
  5. export class TestController {
  6. @Get('public')
  7. publicRoute() {
  8. return 'success';
  9. }
  10. @Allow(Permission.Authenticated)
  11. @Get('restricted')
  12. restrictedRoute() {
  13. return 'success';
  14. }
  15. @Get('bad')
  16. badRoute() {
  17. throw new InternalServerError('uh oh!');
  18. }
  19. }
  20. @VendurePlugin({
  21. controllers: [TestController],
  22. })
  23. export class TestRestPlugin {}