-
Notifications
You must be signed in to change notification settings - Fork 159
Expand file tree
/
Copy pathfastboot-info.js
More file actions
33 lines (28 loc) · 1.02 KB
/
fastboot-info.js
File metadata and controls
33 lines (28 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
'use strict';
const FastBootRequest = require('./fastboot-request');
const FastBootResponse = require('./fastboot-response');
/*
* A class that encapsulates information about the
* current HTTP request from FastBoot. This is injected
* on to the FastBoot service.
*
* @param {ClientRequest} the incoming request object
* @param {ClientResponse} the response object
* @param {Object} additional options passed to fastboot info
* @param {Array} [options.hostWhitelist] expected hosts in your application
* @param {Object} [options.metaData] per request meta data
*/
module.exports = class FastBootInfo {
constructor(request, response, options) {
this.deferredPromise = Promise.resolve();
let { hostWhitelist, metadata } = options;
if (request) {
this.request = new FastBootRequest(request, hostWhitelist);
}
this.response = new FastBootResponse(response || {});
this.metadata = metadata;
}
deferRendering(promise) {
this.deferredPromise = Promise.all([this.deferredPromise, promise]);
}
};