index.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. var _constants = require("../../shared/lib/constants");
  6. var _apiUtils = require("../api-utils");
  7. class BaseNextRequest {
  8. constructor(method, url, body){
  9. this.method = method;
  10. this.url = url;
  11. this.body = body;
  12. }
  13. // Utils implemented using the abstract methods above
  14. get cookies() {
  15. if (this._cookies) return this._cookies;
  16. return this._cookies = (0, _apiUtils).getCookieParser(this.headers)();
  17. }
  18. }
  19. exports.BaseNextRequest = BaseNextRequest;
  20. class BaseNextResponse {
  21. constructor(destination){
  22. this.destination = destination;
  23. }
  24. // Utils implemented using the abstract methods above
  25. redirect(destination, statusCode) {
  26. this.setHeader("Location", destination);
  27. this.statusCode = statusCode;
  28. // Since IE11 doesn't support the 308 header add backwards
  29. // compatibility using refresh header
  30. if (statusCode === _constants.PERMANENT_REDIRECT_STATUS) {
  31. this.setHeader("Refresh", `0;url=${destination}`);
  32. }
  33. return this;
  34. }
  35. }
  36. exports.BaseNextResponse = BaseNextResponse;
  37. //# sourceMappingURL=index.js.map