MCPcopy Index your code
hub / github.com/ember-cli/ember-cli / startHttpServer

Method startHttpServer

lib/tasks/server/express-server.js:208–264  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

206 }
207
208 async startHttpServer() {
209 this.app = this.express();
210 const compression = require('compression');
211 this.app.use(
212 compression({
213 filter(req, res) {
214 let type = res.getHeader('Content-Type');
215
216 if (res.getHeader('x-no-compression')) {
217 // don't compress responses with this response header
218 return false;
219 } else if (type && type.indexOf('text/event-stream') > -1) {
220 // don't attempt to compress server sent events
221 return false;
222 } else {
223 return compression.filter(req, res);
224 }
225 },
226 })
227 );
228
229 this.setupHttpServer();
230
231 let options = this.startOptions;
232 options.httpServer = this.httpServer;
233 let liveReloadServer;
234
235 if (options.path) {
236 liveReloadServer = {
237 setupMiddleware() {},
238 };
239 } else {
240 liveReloadServer = new LiveReloadServer({
241 app: this.app,
242 ui: options.ui,
243 watcher: options.watcher,
244 project: options.project,
245 httpServer: options.httpServer,
246 });
247 }
248
249 const config = this.project.config(options.environment);
250 const middlewareOptions = Object.assign({}, options, {
251 rootURL: config.rootURL,
252 });
253
254 await liveReloadServer.setupMiddleware(this.startOptions);
255 await this.processAppMiddlewares(middlewareOptions);
256 await this.processAddonMiddlewares(middlewareOptions);
257
258 return this.listen(options.port, options.host).catch(() => {
259 throw new SilentError(
260 `Could not serve on http://${this.displayHost(options.host)}:${options.port}. ` +
261 `It is either in use or you do not have permission.`
262 );
263 });
264 }
265

Callers 2

startMethod · 0.95
restartHttpServerMethod · 0.95

Calls 7

setupHttpServerMethod · 0.95
processAppMiddlewaresMethod · 0.95
listenMethod · 0.95
displayHostMethod · 0.95
configMethod · 0.45
setupMiddlewareMethod · 0.45

Tested by

no test coverage detected