nodeHttpToRequest.js 762 B

12345678910111213141516171819202122
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.convertNodeHttpToRequest = void 0;
  4. const apollo_server_env_1 = require("apollo-server-env");
  5. function convertNodeHttpToRequest(req) {
  6. const headers = new apollo_server_env_1.Headers();
  7. Object.keys(req.headers).forEach(key => {
  8. const values = req.headers[key];
  9. if (Array.isArray(values)) {
  10. values.forEach(value => headers.append(key, value));
  11. }
  12. else {
  13. headers.append(key, values);
  14. }
  15. });
  16. return new apollo_server_env_1.Request(req.url, {
  17. headers,
  18. method: req.method,
  19. });
  20. }
  21. exports.convertNodeHttpToRequest = convertNodeHttpToRequest;
  22. //# sourceMappingURL=nodeHttpToRequest.js.map