@adonisjs/http-server 6.5.0-0 → 6.6.0-0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -62,6 +62,10 @@ export declare class Request extends Macroable {
62
62
  cookiesList(): Record<string, any>;
63
63
  cookie(key: string, defaultValue?: string): any;
64
64
  encryptedCookie(key: string, defaultValue?: string): any;
65
+ plainCookie(key: string, options?: {
66
+ defaultValue?: string;
67
+ encoded?: boolean;
68
+ }): any;
65
69
  plainCookie(key: string, defaultValue?: string, encoded?: boolean): any;
66
70
  hasValidSignature(purpose?: string): boolean;
67
71
  toJSON(): {
@@ -3,6 +3,7 @@ import fresh from 'fresh';
3
3
  import typeIs from 'type-is';
4
4
  import accepts from 'accepts';
5
5
  import { isIP } from 'node:net';
6
+ import is from '@sindresorhus/is';
6
7
  import proxyaddr from 'proxy-addr';
7
8
  import lodash from '@poppinss/utils/lodash';
8
9
  import { safeEqual } from '@poppinss/utils';
@@ -278,9 +279,13 @@ export class Request extends Macroable {
278
279
  this.#initiateCookieParser();
279
280
  return this.#cookieParser.decrypt(key) || defaultValue;
280
281
  }
281
- plainCookie(key, defaultValue, encoded) {
282
+ plainCookie(key, defaultValueOrOptions, encoded) {
282
283
  this.#initiateCookieParser();
283
- return this.#cookieParser.decode(key, encoded) || defaultValue;
284
+ if (is.object(defaultValueOrOptions)) {
285
+ return (this.#cookieParser.decode(key, defaultValueOrOptions?.encoded) ||
286
+ defaultValueOrOptions.defaultValue);
287
+ }
288
+ return this.#cookieParser.decode(key, encoded) || defaultValueOrOptions;
284
289
  }
285
290
  hasValidSignature(purpose) {
286
291
  const { signature, ...rest } = this.qs();
@@ -15,7 +15,13 @@ export declare class Response extends Macroable {
15
15
  get hasLazyBody(): boolean;
16
16
  get hasContent(): boolean;
17
17
  get hasStream(): boolean;
18
+ get hasFileToStream(): boolean;
18
19
  get content(): [any, boolean, (string | undefined)?] | undefined;
20
+ get outgoingStream(): ResponseStream | undefined;
21
+ get fileToStream(): {
22
+ path: string;
23
+ generateEtag: boolean;
24
+ } | undefined;
19
25
  lazyBody: Partial<{
20
26
  content: [any, boolean, string?];
21
27
  stream: [ResponseStream, ((error: NodeJS.ErrnoException) => [string, number?])?];
@@ -32,11 +32,25 @@ export class Response extends Macroable {
32
32
  return !!this.lazyBody.content;
33
33
  }
34
34
  get hasStream() {
35
- return !!(this.lazyBody.stream || this.lazyBody.fileToStream);
35
+ return !!this.lazyBody.stream;
36
+ }
37
+ get hasFileToStream() {
38
+ return !!this.lazyBody.fileToStream;
36
39
  }
37
40
  get content() {
38
41
  return this.lazyBody.content;
39
42
  }
43
+ get outgoingStream() {
44
+ return this.lazyBody.stream?.[0];
45
+ }
46
+ get fileToStream() {
47
+ return this.lazyBody.fileToStream
48
+ ? {
49
+ path: this.lazyBody.fileToStream[0],
50
+ generateEtag: this.lazyBody.fileToStream[1],
51
+ }
52
+ : undefined;
53
+ }
40
54
  lazyBody = {};
41
55
  ctx;
42
56
  constructor(request, response, encryption, config, router, qs) {
@@ -267,6 +281,7 @@ export class Response extends Macroable {
267
281
  }
268
282
  removeHeader(key) {
269
283
  key = key.toLowerCase();
284
+ this.response.removeHeader(key);
270
285
  if (this.#headers[key]) {
271
286
  delete this.#headers[key.toLowerCase()];
272
287
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adonisjs/http-server",
3
- "version": "6.5.0-0",
3
+ "version": "6.6.0-0",
4
4
  "description": "AdonisJS HTTP server with support packed with Routing and Cookies",
5
5
  "main": "build/index.js",
6
6
  "type": "module",
@@ -39,12 +39,12 @@
39
39
  "author": "virk,adonisjs",
40
40
  "license": "MIT",
41
41
  "devDependencies": {
42
- "@adonisjs/application": "^6.8.0-0",
43
- "@adonisjs/config": "^4.1.3-0",
44
- "@adonisjs/encryption": "^5.1.0-0",
45
- "@adonisjs/events": "^8.4.3-0",
46
- "@adonisjs/fold": "^9.9.0-0",
47
- "@adonisjs/logger": "^5.3.0-0",
42
+ "@adonisjs/application": "^6.8.1-0",
43
+ "@adonisjs/config": "^4.1.4-0",
44
+ "@adonisjs/encryption": "^5.1.1-0",
45
+ "@adonisjs/events": "^8.4.4-0",
46
+ "@adonisjs/fold": "^9.9.1-0",
47
+ "@adonisjs/logger": "^5.4.0-0",
48
48
  "@commitlint/cli": "^17.4.2",
49
49
  "@commitlint/config-conventional": "^17.4.2",
50
50
  "@fastify/middie": "^8.1.0",
@@ -80,7 +80,7 @@
80
80
  "eslint-config-prettier": "^8.6.0",
81
81
  "eslint-plugin-adonis": "^3.0.3",
82
82
  "eslint-plugin-prettier": "^4.2.1",
83
- "fastify": "^4.11.0",
83
+ "fastify": "^4.12.0",
84
84
  "fs-extra": "^11.1.0",
85
85
  "github-label-sync": "^2.2.0",
86
86
  "http-status-codes": "^2.2.0",
@@ -117,11 +117,11 @@
117
117
  "youch": "^3.2.2"
118
118
  },
119
119
  "peerDependencies": {
120
- "@adonisjs/application": "^6.8.0-0",
121
- "@adonisjs/encryption": "^5.1.0-0",
122
- "@adonisjs/events": "^8.4.3-0",
123
- "@adonisjs/fold": "^9.9.0-0",
124
- "@adonisjs/logger": "^5.3.0-0"
120
+ "@adonisjs/application": "^6.8.1-0",
121
+ "@adonisjs/encryption": "^5.1.1-0",
122
+ "@adonisjs/events": "^8.4.4-0",
123
+ "@adonisjs/fold": "^9.9.1-0",
124
+ "@adonisjs/logger": "^5.4.0-0"
125
125
  },
126
126
  "repository": {
127
127
  "type": "git",