index.d.ts 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /// <reference types="node" />
  2. import type { IncomingHttpHeaders } from 'http';
  3. import type { I18NConfig } from '../config-shared';
  4. import { NextApiRequestCookies } from '../api-utils';
  5. export interface BaseNextRequestConfig {
  6. basePath: string | undefined;
  7. i18n?: I18NConfig;
  8. trailingSlash?: boolean | undefined;
  9. }
  10. export declare abstract class BaseNextRequest<Body = any> {
  11. method: string;
  12. url: string;
  13. body: Body;
  14. protected _cookies: NextApiRequestCookies | undefined;
  15. abstract headers: IncomingHttpHeaders;
  16. constructor(method: string, url: string, body: Body);
  17. abstract parseBody(limit: string | number): Promise<any>;
  18. get cookies(): Partial<{
  19. [key: string]: string;
  20. }>;
  21. }
  22. export declare abstract class BaseNextResponse<Destination = any> {
  23. destination: Destination;
  24. abstract statusCode: number | undefined;
  25. abstract statusMessage: string | undefined;
  26. abstract get sent(): boolean;
  27. constructor(destination: Destination);
  28. /**
  29. * Sets a value for the header overwriting existing values
  30. */
  31. abstract setHeader(name: string, value: string | string[]): this;
  32. /**
  33. * Appends value for the given header name
  34. */
  35. abstract appendHeader(name: string, value: string): this;
  36. /**
  37. * Get all vaues for a header as an array or undefined if no value is present
  38. */
  39. abstract getHeaderValues(name: string): string[] | undefined;
  40. abstract hasHeader(name: string): boolean;
  41. /**
  42. * Get vaues for a header concatenated using `,` or undefined if no value is present
  43. */
  44. abstract getHeader(name: string): string | undefined;
  45. abstract body(value: string): this;
  46. abstract send(): void;
  47. redirect(destination: string, statusCode: number): this;
  48. }