text: "use strict";
  // Copyright IBM Corp. 2018,2020. All Rights Reserved.
  // Node module: @loopback/example-todo
  // This file is licensed under the MIT License.
  // License text available at https://opensource.org/licenses/MIT
  Object.defineProperty(exports, "__esModule", { value: true });
  exports.TodoListApplication = void 0;
  const tslib_1 = require("tslib");
  const boot_1 = require("@loopback/boot");
  const repository_1 = require("@loopback/repository");
  const rest_1 = require("@loopback/rest");
  const rest_explorer_1 = require("@loopback/rest-explorer");
  const service_proxy_1 = require("@loopback/service-proxy");
  const morgan_1 = tslib_1.__importDefault(require("morgan"));
  const path_1 = tslib_1.__importDefault(require("path"));
  const sequence_1 = require("./sequence");
  // ---------- ADD IMPORTS -------------
  const authentication_1 = require("@loopback/authentication");
  const authentication_jwt_1 = require("@loopback/authentication-jwt");
  const datasources_1 = require("./datasources");
  class TodoListApplication extends boot_1.BootMixin(service_proxy_1.ServiceMixin(repository_1.RepositoryMixin(rest_1.RestApplication))) {
      constructor(options = {}) {
          super(options);
          // Set up the custom sequence
          this.sequence(sequence_1.MySequence);
          // Set up default home page
          this.static('/', path_1.default.join(__dirname, '../public'));
          // Customize @loopback/rest-explorer configuration here
          this.configure(rest_explorer_1.RestExplorerBindings.COMPONENT).to({
              path: '/explorer',
          });
          this.component(rest_explorer_1.RestExplorerComponent);
          this.projectRoot = __dirname;
          // Mount authentication system
          this.component(authentication_1.AuthenticationComponent);
          // Mount jwt component
          this.component(authentication_jwt_1.JWTAuthenticationComponent);
          // Bind datasource
          this.dataSource(datasources_1.DbDataSource, authentication_jwt_1.UserServiceBindings.DATASOURCE_NAME);
          // Customize @loopback/boot Booter Conventions here
          this.bootOptions = {
              controllers: {
                  // Customize ControllerBooter Conventions here
                  dirs: ['controllers'],
                  extensions: ['.controller.js'],
                  nested: true,
              },
          };
          this.setupLogging();
      }
      setupLogging() {
          // Register `morgan` express middleware
          // Create a middleware factory wrapper for `morgan(format, options)`
          const morganFactory = (config) => {
              this.debug('Morgan configuration', config);
              return morgan_1.default('combined', config);
          };
          // Print out logs using `debug`
          const defaultConfig = {
              stream: {
                  write: str => {
                      this._debug(str);
                  },
              },
          };
          this.expressMiddleware(morganFactory, defaultConfig, {
              injectConfiguration: 'watch',
              key: 'middleware.morgan',
          });
      }
  }
  exports.TodoListApplication = TodoListApplication;
  //# sourceMappingURL=application.js.map