File: index.js

package info (click to toggle)
node-superagent 9.0.1-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 3,464 kB
  • sloc: javascript: 11,641; makefile: 77
file content (30 lines) | stat: -rw-r--r-- 857 bytes parent folder | download | duplicates (2)
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
const process = require('process');
const express = require('express');

let http2Request;
let http2Res;
if (process.env.HTTP2_TEST) {
  const http2 = require('http2');
  const requestDecorator = require('./requestDecorator');
  const resDecorator = require('./responseDecorator');
  http2Request = requestDecorator(
    Object.create(http2.Http2ServerRequest.prototype)
  );
  http2Res = resDecorator(Object.create(http2.Http2ServerResponse.prototype));
}

function createApp() {
  const app = express();
  if (process.env.HTTP2_TEST) {
    app.request = Object.create(http2Request, {
      app: { configurable: true, enumerable: true, writable: true, value: app }
    });
    app.response = Object.create(http2Res, {
      app: { configurable: true, enumerable: true, writable: true, value: app }
    });
  }

  return app;
}

module.exports = createApp;