forked from loafle/openapi-generator-original
		
	* Updated to new nodejs packages, depending heavily on express-openapi-validator. Requires quite a change in code. Updated the business-logic in the controllers/Controller.js file. Logger now records also timestamp of events. Files are uploaded according to definition in config.js file * Removed commented-out code; Changed openApi document extensions to suit new express-openapi-validator definition; multipart and file uploading is supported now; Automatic response returns the values the were sent in the request * fixed README documentation, fixed a mistage in package.json/mustache * added generated files that were created when running the ./bin/test file
		
			
				
	
	
		
			31 lines
		
	
	
		
			770 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			31 lines
		
	
	
		
			770 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
const ExpressServer = require('./expressServer');
 | 
						|
const logger = require('./logger');
 | 
						|
// const swaggerRouter = require('./utils/swaggerRouter');
 | 
						|
 | 
						|
class App {
 | 
						|
  constructor(config) {
 | 
						|
    this.config = config;
 | 
						|
  }
 | 
						|
 | 
						|
  async launch() {
 | 
						|
    try {
 | 
						|
      this.expressServer = new ExpressServer(this.config.URL_PORT, this.config.OPENAPI_YAML);
 | 
						|
      // this.expressServer.app.use(swaggerRouter());
 | 
						|
      await this.expressServer.launch();
 | 
						|
      logger.info('Express server running');
 | 
						|
    } catch (error) {
 | 
						|
      logger.error(error);
 | 
						|
      await this.close();
 | 
						|
    }
 | 
						|
  }
 | 
						|
 | 
						|
  async close() {
 | 
						|
    if (this.expressServer !== undefined) {
 | 
						|
      await this.expressServer.close();
 | 
						|
      logger.info(`Server shut down on port ${this.config.URL_PORT}`);
 | 
						|
    }
 | 
						|
  }
 | 
						|
}
 | 
						|
 | 
						|
module.exports = App;
 |