Every line of 'app configure express' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.
8 function configureApp() { 9 10 app.get('/sayHello', function (req, res){ 11 res.send('hello', 200); 12 }); 13 14 return app; 15 }
42 async setupExpress() { 43 this.app = express(); 44 this.app.disable('x-powered-by'); 45 this.app.use('/healthcheck', require('./../route/healthcheck')); 46 this.app.use('/grafana-proxy', require('../route/grafana-proxy')); 47 }
42 export function configureAuth(express: exp.Express): void { 43 const authParser = require("express-auth-parser"); 44 express.use(authParser); 45 }
40 configureServer(app, middlewares, mode) { 41 if (mode !== 'static') { 42 const helmet = require('helmet'); 43 const express = require('express'); 44 const mime = require('mime'); 45 const { distDir } = this.config; 46 middlewares.initial.push(helmet()); 47 middlewares.files.push( 48 express.static(distDir, { 49 maxAge: '1y', 50 setHeaders: (res, filePath) => { 51 const { noCache } = res.locals || {}; 52 if (noCache || mime.getType(filePath) === 'text/html') { 53 helmet.noCache()(null, res, () => {}); 54 } 55 }, 56 redirect: false, 57 }) 58 ); 59 middlewares.postfiles.push(helmet.noCache()); 60 if (typeof this.getLogger === 'function') { 61 const loggerMiddleware = require('../lib/log'); 62 app.use(loggerMiddleware(this.getLogger())); 63 } 64 } 65 }
23 setup(app: Readonly) { 24 app.koa.use(BodyParser(this.opt && this.opt.bodyParser)) 25 app.koa.use(Cors(this.opt && this.opt.cors)) 26 if(this.opt && this.opt.dependencyResolver) 27 app.set({ dependencyResolver: this.opt.dependencyResolver }) 28 if (this.opt && this.opt.controller) 29 app.set({ controller: this.opt.controller }) 30 }
42 init() { 43 const port = Locals_1.default.config().port; 44 // Registering Exception / Error Handlers 45 this.express.use(Handler_1.default.logErrors); 46 this.express.use(Handler_1.default.clientErrorHandler); 47 this.express.use(Handler_1.default.errorHandler); 48 this.express = Handler_1.default.notFoundHandler(this.express); 49 // Start the server on the specified port 50 this.express.listen(port, (_error) => { 51 if (_error) { 52 return console.log('Error: ', _error); 53 } 54 return console.log('\x1b[33m%s\x1b[0m', `Server :: Running @ 'http://localhost:${port}'`); 55 }); 56 }
12 createApp(opts) { 13 return this.express(opts); 14 }
42 get Express(): express.Application { 43 return this.express; 44 }
12 instance.configure = function configure(partialsPath) { 13 var hbsOptions = { 14 partialsDir: [config.get('paths').helperTemplates], 15 onCompile: function onCompile(exhbs, source) { 16 return exhbs.handlebars.compile(source, {preventIndent: true}); 17 } 18 }; 19 20 if (partialsPath) { 21 hbsOptions.partialsDir.push(partialsPath); 22 } 23 24 return instance.express4(hbsOptions); 25 };
24 function configActiveRoute(expressApp) { 25 // Get named router 26 var router = expressApp.get('router'); 27 28 if (router === undefined) { 29 return; 30 } 31 32 expressApp.use(function(request, response, next) { 33 var route = router.match(request) 34 if (route) { 35 activeRoute = route.route.options.name 36 } 37 next() 38 }); 39 }