MCPcopy
hub / github.com/tomdionysus/foaas / constructor

Method constructor

lib/foaas.js:29–108  ·  view source on GitHub ↗
(options)

Source from the content-addressed store, hash-verified

27 }
28
29 constructor (options) {
30 // Internal State.
31 this.sendFucks = this.sendFucks.bind(this)
32 this.send622 = this.send622.bind(this)
33 this.loadRenderers = this.loadRenderers.bind(this)
34 this.loadFilters = this.loadFilters.bind(this)
35 this.loadOperations = this.loadOperations.bind(this)
36 this.do = this.do.bind(this)
37 this.start = this.start.bind(this)
38 this.output = this.output.bind(this)
39 this.process = this.process.bind(this)
40 this.operations = {}
41 this.operationsArray = []
42 this.formats = {}
43 this.formatsArray = []
44 this.filters = {}
45 this.fucks = ''
46
47 // Main App
48 this.app = express()
49 this.app.disable('x-powered-by')
50
51 // Redirect HTTPS
52 if (process.env.ENV === 'prod') {
53 this.app.use((req, res, next) => { this.httpsRedirect(req, res, next) })
54 }
55
56 // GZip
57 this.app.use(compression())
58
59 // Plugin Paths
60 const renderersPath = options.renderersPath || 'renderers'
61 const filtersPath = options.filtersPath || 'filters'
62 const operationsPath = options.operationsPath || 'operations'
63
64 // A man is not dead while his name is still spoken.
65 this.app.use(function (req, res, next) {
66 res.header('X-Clacks-Overhead', 'GNU Terry Pratchett')
67 return next()
68 })
69
70 // Standard Middleware
71 this.app.use(bodyParser.json({ extended: true, strict: false }))
72 this.app.use(bodyParser.urlencoded({ extended: true }))
73 this.app.use(bodyParser.text({ extended: true }))
74 this.app.use(methodOverride())
75
76 // Load Filters
77 this.loadFilters(filtersPath)
78
79 // Send very permissive CORS headers.
80 this.app.use(function (req, res, next) {
81 res.header('Access-Control-Allow-Origin', '*')
82 res.header('Access-Control-Allow-Methods', 'GET, OPTIONS')
83 res.header('Access-Control-Allow-Headers', 'Content-Type')
84 return next()
85 })
86

Callers

nothing calls this directly

Calls 4

httpsRedirectMethod · 0.95
loadFiltersMethod · 0.95
loadOperationsMethod · 0.95
loadRenderersMethod · 0.95

Tested by

no test coverage detected