f50438e76f
* ui: Split up client/http and replace $.ajax This splits the client/http service more in the following ways: 1. Connections are now split out into its own service 2. The transport is now split out into its own service that returns a listener based http transport 3. Various string parsing/stringifying functions are now split out into utils * Remove jQuery from our production build * Move the coverage serving to the server.js file * Self review amends * Add X-Requested-With header * Move some files around, externalize some functions * Move connection tracking to use native Set * Ensure HTTP parsing doesn't encode headers In the future this will change to deal with all HTTP parsing in one place, hence the commented out METHOD_PARSING etc * Start to fix up integration tests to use requestParams
55 lines
1.7 KiB
JavaScript
55 lines
1.7 KiB
JavaScript
/* eslint-env node */
|
|
'use strict';
|
|
//
|
|
const $ = process.env;
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
const promisify = require('util').promisify;
|
|
const read = promisify(fs.readFile);
|
|
const apiDouble = require('@hashicorp/api-double');
|
|
|
|
const apiDoubleHeaders = require('@hashicorp/api-double/lib/headers');
|
|
const cookieParser = require('cookie-parser');
|
|
const bodyParser = require('body-parser');
|
|
|
|
//
|
|
module.exports = {
|
|
name: 'startup',
|
|
serverMiddleware: function(server) {
|
|
// TODO: see if we can move these into the project specific `/server` directory
|
|
// instead of inside an addon
|
|
|
|
// TODO: This should all be moved out into ember-cli-api-double
|
|
// and we should figure out a way to get to the settings here for
|
|
// so we can set this path name centrally in config
|
|
// TODO: undefined here is a possible faker salt that we should be able
|
|
// to pass in from ember serve/config somehow
|
|
const dir = path.resolve('./node_modules/@hashicorp/consul-api-double');
|
|
const controller = apiDouble(undefined, dir, read, $, path.resolve);
|
|
[
|
|
apiDoubleHeaders(),
|
|
cookieParser(),
|
|
bodyParser.text({ type: '*/*' }),
|
|
controller().serve,
|
|
].reduce(function(app, item) {
|
|
return app.use(item);
|
|
}, server.app);
|
|
},
|
|
contentFor: function(type, config) {
|
|
const vars = {
|
|
appName: config.modulePrefix,
|
|
environment: config.environment,
|
|
rootURL: config.environment === 'production' ? '{{.ContentPath}}' : config.rootURL,
|
|
config: config,
|
|
};
|
|
switch (type) {
|
|
case 'head':
|
|
return require('./templates/head.html.js')(vars);
|
|
case 'body':
|
|
return require('./templates/body.html.js')(vars);
|
|
case 'root-class':
|
|
return 'ember-loading';
|
|
}
|
|
},
|
|
};
|