-
Notifications
You must be signed in to change notification settings - Fork 0
/
servomatic.js.map
1 lines (1 loc) · 14.1 KB
/
servomatic.js.map
1
{"version":3,"sources":["src/lib/api.js","src/lib/errorHandler.js","src/lib/killer.js","src/lib/logger.js","src/lib/view.js","src/servomatic.js","src/static/index.js"],"names":[],"mappings":";;;;;;IAAkB,MAAM,WAAO,SAAS,EAAhC,MAAM;;IACN,GAAG,WAAO,MAAM,EAAhB,GAAG;;AAEJ,IAAI,GAAG,GAAG,MAAM,EAAE,CAAA;;QAAd,GAAG,GAAH,GAAG;AAEd,IAAI,YAAY,GAAG,IAAI;IACnB,mBAAmB,GAAG,IAAI;IAC1B,OAAO,CACV;;AAED,SAAS,QAAQ,CAAC,GAAG,EAAE;AACrB,MAAK,YAAY,EAAG;AAClB,WAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;GAClB;CACF;;AAED,GAAG,CAAC,GAAG,CAAE,UAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAK;AAC3B,MAAI,GAAG,6BAA2B,GAAG,CAAC,WAAW,AAAE,CAAC;AACpD,UAAQ,mBAAiB,GAAG,CAAG,CAAC;;AAEhC,KAAG,CAAC,GAAG,EAAE,UAAC,MAAM,EAAK;AACnB,YAAQ,0BAAwB,MAAM,CAAC,UAAU,CAAG,CAAC;AACrD,OAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,wGAAoG,GAAG,CAAG,CAAC;GAChI,CAAC,CAAC,EAAE,CAAC,OAAO,EAAE,UAAC,CAAC,EAAK;AACpB,YAAQ,CAAC,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC;AAClC,OAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,sCAAkC,CAAC,CAAC,KAAK,yBAAoB,CAAC,CAAC,OAAO,CAAG,CAAC;GAC/F,CAAC,CAAC;CACJ,CAAC,CAAC;;qBAEY,GAAG;;;;;;;AC7BX,IAAI,YAAY,GAAG;;AAExB,aAAW,EA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var debugLogging = true\n , lastRequestFinished = true\n , lastUrl\n;\n\nfunction debugLog(str) {\n if ( debugLogging ) {\n console.log(str);\n }\n}\n\napi.use( (req, res, next) => {\n var url = `http://127.0.0.1:8080${req.originalUrl}`;\n debugLog(`loading url: ${url}`);\n\n get(url, (result) => {\n debugLog(`slackomatic get res ${result.statusCode}`);\n res.status(200).send(`Slackomatic get request <span color=\"green\">succeeded</span>: redirected request to backend url ${url}`);\n }).on('error', (e) => {\n debugLog(\"Got error: \" + e.errno);\n res.status(500).send(`Slackomatic <span color=\"red\">${e.errno} errored</span>: ${e.message}`);\n });\n});\n\nexport default api;\n","export var errorHandler = {\n //development errorHandler, renders error page\n development(err, req, res, next) {\n var message = {\n message: err.message,\n error: err\n };\n res.status(err.status || 500)\n .send(`error : ${JSON.stringify(message)}`)\n ;\n },\n\n // production error handler\n // no stacktraces leaked to user\n production(err, req, res, next) {\n res.status(err.status || 500).send('error');\n }\n};\n\nexport default errorHandler;\n","import {Router as router} from 'express';\n\nexport var killer = router();\n\nkiller.get('/killkillkill', (req, res, next) => {\n res.status(200).send('killed process');\n process.exit(0);\n});\n\nexport default killer;\n","//logging middleware\nimport morgan from 'morgan';\nimport {join} from 'path';\nimport {createWriteStream as wStream, existsSync} from 'fs';\nimport merge from 'magic-merge';\nimport {each} from 'magic-loops';\nimport mkdirp from 'mkdirp';\n\nvar self;\n\nclass Logger {\n constructor(app, opts = {}) {\n var cwd = process.cwd()\n , defaultDir = join('/var', 'log', 'servomatic')\n ;\n\n self = this;\n self.dir = opts.dir || join(cwd, 'log')\n\n if ( ! existsSync(self.dir) ) {\n console.log(`log dir at ${self.dir} does not exist, creating ${defaultDir}`);\n self.dir = defaultDir;\n mkdirp(self.dir, {mode: 644} );\n }\n\n self.logs = merge(opts, {\n access: {\n stream: wStream( join(self.dir, 'access.log'), {flags: 'a'} )\n , skip: function (req, res) { return res.statusCode >= 400 }\n }\n , err : {\n stream: wStream( join(self.dir, 'error.log'), {flags: 'a'} )\n , skip: function (req, res) { return res.statusCode < 400 }\n }\n });\n\n self.app = app;\n }\n\n middleware() {\n each(self.logs, (log) => {\n self.app.use( morgan('default', log) )\n });\n }\n}\n\nexport default Logger;\n","export function view(req, res, next) {\n res.render('pages/' + req.params.page, (err, html) => {\n if ( err || ! html ) { next(err); }\n\n res.status(200).send(html);\n });\n}\n\nexport default view;\n","import express from 'express';\nimport {get} from 'http';\nimport {join} from 'path';\nimport Favicon from 'magic-favicon';\nimport {existsSync} from 'fs';\nimport minimist from 'minimist';\n\nvar servomatic = express()\n , env = servomatic.get('env')\n , cwd = process.cwd()\n , argv = minimist( process.argv.slice(2) )\n;\n\nif ( argv.dir && typeof argv.dir === 'string' ) {\n if ( argv.dir.indexOf('/') === 0 ) {\n cwd = argv.dir;\n } else {\n cwd = join( cwd, argv.dir );\n }\n}\n\nvar dirs = {\n static : join(cwd, 'static')\n , public : join(cwd, 'public')\n , views : join(cwd, 'views')\n , favicon : join(cwd, 'favicon.ico')\n , worstCase: join(__dirname, 'dist')\n }\n , logger = new Logger( servomatic )\n;\n\nconsole.log(`executing in cwd: ${cwd}`);\n\nservomatic.set('port', process.env.PORT || 80);\n\n// view engine setup for the rare cases where no html file exists\nservomatic.set('views', dirs.views);\nservomatic.set('view engine', 'jade');\n\nnew Favicon(servomatic, dirs.favicon);\n\n//if requested path exists in /public it gets served from there\nservomatic.use( express.static(dirs.public) );\n\nlogger.middleware(servomatic);\n\n//servomaticomatic api redirect\nservomatic.use('/slackomatic/*', api);\n\nservomatic.use(killer);\n\nservomatic.use( express.static( dirs.static, {\n extensions: ['html'] //automatically add html extension to urls\n, index: ['index.html'] //always load index.html files on /\n}));\n\n//renders :page from views/pages if static html does not exist\nservomatic.use('/:page', view);\n\nservomatic.use( express.static(dirs.worstCase) );\n\n// catch 404 and forwarding to error handler\nservomatic.use( (req, res, next) => {\n var err = new Error('Not Found');\n err.status = 404;\n next(err);\n});\n\n// error handlers\n// development error handler prints stacktrace\nif ( ! errorHandler.hasOwnProperty(env) ) {\n env = 'production';\n}\n\nservomatic.use( errorHandler[env] );\n\nservomatic.listen( servomatic.get('port'), () => {\n console.log(`servomatic listens on port : ${servomatic.get('port')}`);\n} );\n","(function() {\n console.log('hello world');\n})();\n"]}