@adonisjs/http-server 7.0.0-1 → 7.0.0-3

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.
Files changed (65) hide show
  1. package/build/chunk-NC6OWANS.js +4437 -0
  2. package/build/chunk-NC6OWANS.js.map +1 -0
  3. package/build/factories/http_server.d.ts +1 -0
  4. package/build/factories/main.js +332 -14
  5. package/build/factories/main.js.map +1 -0
  6. package/build/index.js +309 -22
  7. package/build/index.js.map +1 -0
  8. package/build/src/define_middleware.d.ts +2 -1
  9. package/build/src/router/lookup_store/main.d.ts +1 -3
  10. package/build/src/router/lookup_store/route_finder.d.ts +5 -1
  11. package/build/src/router/main.d.ts +5 -4
  12. package/build/src/router/resource.d.ts +19 -7
  13. package/build/src/types/main.js +1 -15
  14. package/build/src/types/main.js.map +1 -0
  15. package/build/src/types/middleware.d.ts +3 -1
  16. package/package.json +60 -59
  17. package/build/factories/http_context.js +0 -51
  18. package/build/factories/http_server.js +0 -26
  19. package/build/factories/qs_parser_factory.js +0 -44
  20. package/build/factories/request.js +0 -73
  21. package/build/factories/response.js +0 -77
  22. package/build/factories/router.js +0 -45
  23. package/build/factories/server_factory.js +0 -65
  24. package/build/src/cookies/client.js +0 -84
  25. package/build/src/cookies/drivers/encrypted.js +0 -36
  26. package/build/src/cookies/drivers/plain.js +0 -33
  27. package/build/src/cookies/drivers/signed.js +0 -36
  28. package/build/src/cookies/parser.js +0 -167
  29. package/build/src/cookies/serializer.js +0 -79
  30. package/build/src/debug.js +0 -10
  31. package/build/src/define_config.js +0 -68
  32. package/build/src/define_middleware.js +0 -35
  33. package/build/src/exception_handler.js +0 -306
  34. package/build/src/exceptions.js +0 -38
  35. package/build/src/helpers.js +0 -105
  36. package/build/src/http_context/local_storage.js +0 -39
  37. package/build/src/http_context/main.js +0 -105
  38. package/build/src/qs.js +0 -25
  39. package/build/src/redirect.js +0 -140
  40. package/build/src/request.js +0 -865
  41. package/build/src/response.js +0 -1208
  42. package/build/src/router/brisk.js +0 -85
  43. package/build/src/router/executor.js +0 -30
  44. package/build/src/router/factories/use_return_value.js +0 -22
  45. package/build/src/router/group.js +0 -207
  46. package/build/src/router/lookup_store/main.js +0 -86
  47. package/build/src/router/lookup_store/route_finder.js +0 -49
  48. package/build/src/router/lookup_store/url_builder.js +0 -209
  49. package/build/src/router/main.js +0 -316
  50. package/build/src/router/matchers.js +0 -36
  51. package/build/src/router/parser.js +0 -17
  52. package/build/src/router/resource.js +0 -216
  53. package/build/src/router/route.js +0 -293
  54. package/build/src/router/store.js +0 -195
  55. package/build/src/server/factories/final_handler.js +0 -30
  56. package/build/src/server/factories/middleware_handler.js +0 -16
  57. package/build/src/server/factories/write_response.js +0 -24
  58. package/build/src/server/main.js +0 -292
  59. package/build/src/types/base.js +0 -9
  60. package/build/src/types/middleware.js +0 -9
  61. package/build/src/types/qs.js +0 -9
  62. package/build/src/types/request.js +0 -9
  63. package/build/src/types/response.js +0 -9
  64. package/build/src/types/route.js +0 -9
  65. package/build/src/types/server.js +0 -9
@@ -1,140 +0,0 @@
1
- /*
2
- * @adonisjs/http-server
3
- *
4
- * (c) AdonisJS
5
- *
6
- * For the full copyright and license information, please view the LICENSE
7
- * file that was distributed with this source code.
8
- */
9
- import { parse } from 'node:url';
10
- import encodeUrl from 'encodeurl';
11
- import debug from './debug.js';
12
- /**
13
- * Exposes the API to construct redirect routes
14
- */
15
- export class Redirect {
16
- /**
17
- * A boolean to forward the existing query string
18
- */
19
- #forwardQueryString = false;
20
- /**
21
- * The status code for the redirect
22
- */
23
- #statusCode = 302;
24
- /**
25
- * A custom query string to forward
26
- */
27
- #queryString = {};
28
- #request;
29
- #response;
30
- #router;
31
- #qs;
32
- constructor(request, response, router, qs) {
33
- this.#request = request;
34
- this.#response = response;
35
- this.#router = router;
36
- this.#qs = qs;
37
- }
38
- /**
39
- * Sends response by setting require headers
40
- */
41
- #sendResponse(url, query) {
42
- const stringified = this.#qs.stringify(query);
43
- url = stringified ? `${url}?${stringified}` : url;
44
- debug('redirecting to url "%s"', url);
45
- this.#response.location(encodeUrl(url));
46
- this.#response.safeStatus(this.#statusCode);
47
- this.#response.type('text/plain; charset=utf-8');
48
- this.#response.send(`Redirecting to ${url}`);
49
- }
50
- /**
51
- * Returns the referrer url
52
- */
53
- #getReferrerUrl() {
54
- let url = this.#request.headers['referer'] || this.#request.headers['referrer'] || '/';
55
- return Array.isArray(url) ? url[0] : url;
56
- }
57
- /**
58
- * Set a custom status code.
59
- */
60
- status(statusCode) {
61
- this.#statusCode = statusCode;
62
- return this;
63
- }
64
- /**
65
- * Clearing query string values added using the
66
- * "withQs" method
67
- */
68
- clearQs() {
69
- this.#forwardQueryString = false;
70
- this.#queryString = {};
71
- return this;
72
- }
73
- withQs(name, value) {
74
- if (typeof name === 'undefined') {
75
- this.#forwardQueryString = true;
76
- return this;
77
- }
78
- if (typeof name === 'string') {
79
- this.#queryString[name] = value;
80
- return this;
81
- }
82
- Object.assign(this.#queryString, name);
83
- return this;
84
- }
85
- /**
86
- * Redirect to the previous path.
87
- */
88
- back() {
89
- let query = {};
90
- const referrerUrl = this.#getReferrerUrl();
91
- const url = parse(referrerUrl);
92
- debug('referrer url "%s"', referrerUrl);
93
- debug('referrer base url "%s"', url.pathname);
94
- /**
95
- * Parse query string from the referrer url
96
- */
97
- if (this.#forwardQueryString) {
98
- query = this.#qs.parse(url.query || '');
99
- }
100
- /**
101
- * Append custom query string
102
- */
103
- Object.assign(query, this.#queryString);
104
- /**
105
- * Redirect
106
- */
107
- this.#sendResponse(url.pathname || '', query);
108
- }
109
- /**
110
- * Redirect the request using a route identifier.
111
- */
112
- toRoute(routeIdentifier, params, options) {
113
- if (options && options.qs) {
114
- this.withQs(options.qs);
115
- options.qs = undefined;
116
- }
117
- const url = this.#router.makeUrl(routeIdentifier, params, options);
118
- return this.toPath(url);
119
- }
120
- /**
121
- * Redirect the request using a path.
122
- */
123
- toPath(url) {
124
- let query = {};
125
- /**
126
- * Extract query string from the current URL
127
- */
128
- if (this.#forwardQueryString) {
129
- query = this.#qs.parse(parse(this.#request.url).query || '');
130
- }
131
- /**
132
- * Assign custom query string
133
- */
134
- Object.assign(query, this.#queryString);
135
- /**
136
- * Redirect
137
- */
138
- this.#sendResponse(url, query);
139
- }
140
- }