Advertisement
Guest User

Untitled

a guest
Apr 20th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. import {BootMixin} from '@loopback/boot';
  2. import {ApplicationConfig} from '@loopback/core';
  3. import {RestExplorerBindings, RestExplorerComponent} from '@loopback/rest-explorer';
  4. import {RepositoryMixin} from '@loopback/repository';
  5. import {RestApplication} from '@loopback/rest';
  6. import {ServiceMixin} from '@loopback/service-proxy';
  7. import * as path from 'path';
  8. import {MySequence} from './sequence';
  9. import {AuthenticationComponent, AuthenticationBindings} from '@loopback/authentication';
  10. import {MyAuthMetadataProvider, MyAuthStrategyProvider, MyAuthActionProvider} from './auth';
  11.  
  12. export class Lb4JwtRoleBasedAuthSampleApplication extends BootMixin(ServiceMixin(RepositoryMixin(RestApplication))) {
  13. constructor(options: ApplicationConfig = {}) {
  14. super(options);
  15.  
  16. // Set up the custom sequence
  17. this.sequence(MySequence);
  18.  
  19. // Set up default home page
  20. this.static('/', path.join(__dirname, '../public'));
  21.  
  22. // Customize @loopback/rest-explorer configuration here
  23. this.bind(RestExplorerBindings.CONFIG).to({
  24. path: '/explorer',
  25. });
  26. this.component(RestExplorerComponent);
  27.  
  28. // enable authenticationcomponent
  29. this.component(AuthenticationComponent);
  30. // bind authentication bindings to our custom providers
  31. this.bind(AuthenticationBindings.METADATA).toProvider(MyAuthMetadataProvider);
  32. this.bind(AuthenticationBindings.STRATEGY).toProvider(MyAuthStrategyProvider);
  33. this.bind(AuthenticationBindings.AUTH_ACTION).toProvider(MyAuthActionProvider);
  34.  
  35. this.projectRoot = __dirname;
  36. // Customize @loopback/boot Booter Conventions here
  37. this.bootOptions = {
  38. controllers: {
  39. // Customize ControllerBooter Conventions here
  40. dirs: ['controllers'],
  41. extensions: ['.controller.js'],
  42. nested: true,
  43. },
  44. };
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement