@arkstack/http 0.19.2 → 0.19.4
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.
- package/README.md +4 -4
- package/dist/app.d.ts +6 -7
- package/dist/index.js +1 -1
- package/dist/{redirect-g4KUj_g-.js → redirect-D4Oybkdd.js} +15 -15
- package/dist/setup.js +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
HTTP module for Arkstack, providing framework-agnostic request and response primitives.
|
|
6
6
|
|
|
7
7
|
```ts
|
|
8
|
-
import { Request, Response } from '@arkstack/http'
|
|
8
|
+
import { Request, Response } from '@arkstack/http'
|
|
9
9
|
|
|
10
10
|
const request = Request.from({
|
|
11
11
|
headers: {
|
|
@@ -13,11 +13,11 @@ const request = Request.from({
|
|
|
13
13
|
},
|
|
14
14
|
method: 'GET',
|
|
15
15
|
path: '/account',
|
|
16
|
-
})
|
|
16
|
+
})
|
|
17
17
|
|
|
18
|
-
const token = request.bearerToken()
|
|
18
|
+
const token = request.bearerToken()
|
|
19
19
|
|
|
20
|
-
const response = new Response().status(200).json({ ok: true })
|
|
20
|
+
const response = new Response().status(200).json({ ok: true })
|
|
21
21
|
```
|
|
22
22
|
|
|
23
23
|
Runtime-specific handlers should continue to use their native framework request and response objects. Driver middleware can translate those objects into `@arkstack/http` wrappers when calling shared services.
|
package/dist/app.d.ts
CHANGED
|
@@ -7,32 +7,31 @@ declare module 'clear-router' {
|
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
|
|
11
10
|
declare module 'node:http' {
|
|
12
11
|
interface IncomingMessage {
|
|
13
12
|
rawBody?: Buffer
|
|
14
|
-
session?: AuthSession | undefined
|
|
13
|
+
session?: AuthSession | undefined
|
|
15
14
|
}
|
|
16
15
|
}
|
|
17
16
|
|
|
18
17
|
declare module 'clear-router/types/h3' {
|
|
19
18
|
interface HttpRequest {
|
|
20
19
|
rawBody?: Buffer
|
|
21
|
-
session?: AuthSession | undefined
|
|
20
|
+
session?: AuthSession | undefined
|
|
22
21
|
}
|
|
23
22
|
}
|
|
24
23
|
|
|
25
24
|
declare module 'clear-router' {
|
|
26
25
|
interface HttpRequests {
|
|
27
26
|
rawBody?: Buffer
|
|
28
|
-
session?: AuthSession | undefined
|
|
27
|
+
session?: AuthSession | undefined
|
|
29
28
|
}
|
|
30
29
|
}
|
|
31
30
|
|
|
32
31
|
declare module 'h3' {
|
|
33
32
|
interface H3EventContext {
|
|
34
33
|
rawBody?: Buffer
|
|
35
|
-
session?: AuthSession | undefined
|
|
34
|
+
session?: AuthSession | undefined
|
|
36
35
|
}
|
|
37
36
|
}
|
|
38
37
|
|
|
@@ -40,7 +39,7 @@ declare global {
|
|
|
40
39
|
namespace Express {
|
|
41
40
|
interface Request {
|
|
42
41
|
rawBody?: Buffer
|
|
43
|
-
session?: AuthSession | undefined
|
|
42
|
+
session?: AuthSession | undefined
|
|
44
43
|
}
|
|
45
44
|
}
|
|
46
|
-
}
|
|
45
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as registerResponseFlashSweep, B as setRequestResolver, C as parseCookies, D as attachViewState, E as signValue, F as ErrorBag, G as normalizeHeaders, H as isRecord, I as FlashBag, K as resolveMiddleware, L as Response, M as Session, N as clearFallbackSession, O as ensureSession, P as setSessionResolver, R as setResponseResolver, S as getCookie, T as setCookie, U as makeHeaders, V as isHeaders, W as normalizeHeaderValue, _ as decodeJson, a as kanunSessionPlugin, b as encodeSignedValue, c as getSessionDriver, d as CookieSessionDriver, f as BaseSessionDriver, g as encodeSessionPayload, h as decodeSessionPayload, i as arkstackHttpPlugin, j as old, k as getSession, l as FileSessionDriver, m as encryptSessionValue, n as redirectBackTarget, o as configureSession, p as decryptSessionValue, q as unwrapRequestSource, r as resolveRedirectTarget, s as createSessionDriver, t as redirect, u as DatabaseSessionDriver, v as decodeSignedValue, w as serializeCookie, x as generateSessionId, y as encodeJson, z as Request } from "./redirect-
|
|
1
|
+
import { A as registerResponseFlashSweep, B as setRequestResolver, C as parseCookies, D as attachViewState, E as signValue, F as ErrorBag, G as normalizeHeaders, H as isRecord, I as FlashBag, K as resolveMiddleware, L as Response, M as Session, N as clearFallbackSession, O as ensureSession, P as setSessionResolver, R as setResponseResolver, S as getCookie, T as setCookie, U as makeHeaders, V as isHeaders, W as normalizeHeaderValue, _ as decodeJson, a as kanunSessionPlugin, b as encodeSignedValue, c as getSessionDriver, d as CookieSessionDriver, f as BaseSessionDriver, g as encodeSessionPayload, h as decodeSessionPayload, i as arkstackHttpPlugin, j as old, k as getSession, l as FileSessionDriver, m as encryptSessionValue, n as redirectBackTarget, o as configureSession, p as decryptSessionValue, q as unwrapRequestSource, r as resolveRedirectTarget, s as createSessionDriver, t as redirect, u as DatabaseSessionDriver, v as decodeSignedValue, w as serializeCookie, x as generateSessionId, y as encodeJson, z as Request } from "./redirect-D4Oybkdd.js";
|
|
2
2
|
//#region src/middlewares/web.ts
|
|
3
3
|
const webMiddlewareKey = Symbol.for("arkstack:http:web");
|
|
4
4
|
const markWebRequest = (target) => {
|
|
@@ -8,9 +8,9 @@ import { Arkstack } from "@arkstack/contract";
|
|
|
8
8
|
//#region src/helpers.ts
|
|
9
9
|
/**
|
|
10
10
|
* Checks and asserts if target is a class
|
|
11
|
-
*
|
|
12
|
-
* @param target
|
|
13
|
-
* @returns
|
|
11
|
+
*
|
|
12
|
+
* @param target
|
|
13
|
+
* @returns
|
|
14
14
|
*/
|
|
15
15
|
const isClass = (target) => {
|
|
16
16
|
return typeof target === "function" && /^class\s/.test(Function.prototype.toString.call(target));
|
|
@@ -51,9 +51,9 @@ const isRecord = (value) => {
|
|
|
51
51
|
};
|
|
52
52
|
/**
|
|
53
53
|
* Resolve Middleware
|
|
54
|
-
*
|
|
55
|
-
* @param middleware
|
|
56
|
-
* @returns
|
|
54
|
+
*
|
|
55
|
+
* @param middleware
|
|
56
|
+
* @returns
|
|
57
57
|
*/
|
|
58
58
|
const resolveMiddleware = (middleware) => {
|
|
59
59
|
if (!middleware || typeof middleware === "function" && !isClass(middleware)) return middleware;
|
|
@@ -88,7 +88,7 @@ const setFallbackRequest = (request) => {
|
|
|
88
88
|
};
|
|
89
89
|
/**
|
|
90
90
|
* Represents an HTTP request, providing a consistent interface for accessing request data.
|
|
91
|
-
*
|
|
91
|
+
*
|
|
92
92
|
* @author 3m1n3nc3
|
|
93
93
|
*/
|
|
94
94
|
var Request$1 = class Request$1 extends Request {
|
|
@@ -236,7 +236,7 @@ const setFallbackResponse = (response) => {
|
|
|
236
236
|
};
|
|
237
237
|
/**
|
|
238
238
|
* Represents an HTTP response, providing a consistent interface for accessing response data.
|
|
239
|
-
*
|
|
239
|
+
*
|
|
240
240
|
* @author 3m1n3nc3
|
|
241
241
|
*/
|
|
242
242
|
var Response$1 = class Response$1 extends Response {
|
|
@@ -863,10 +863,10 @@ const attachViewState = (target, session) => {
|
|
|
863
863
|
};
|
|
864
864
|
/**
|
|
865
865
|
* Ensure a valid session exists
|
|
866
|
-
*
|
|
867
|
-
* @param ctx
|
|
868
|
-
* @param initial
|
|
869
|
-
* @returns
|
|
866
|
+
*
|
|
867
|
+
* @param ctx
|
|
868
|
+
* @param initial
|
|
869
|
+
* @returns
|
|
870
870
|
*/
|
|
871
871
|
const ensureSession = (ctx, initial, persistent) => {
|
|
872
872
|
if (!isRecord(ctx)) return new Session(initial, persistent);
|
|
@@ -878,9 +878,9 @@ const ensureSession = (ctx, initial, persistent) => {
|
|
|
878
878
|
};
|
|
879
879
|
/**
|
|
880
880
|
* Get the current session
|
|
881
|
-
*
|
|
882
|
-
* @param ctx
|
|
883
|
-
* @returns
|
|
881
|
+
*
|
|
882
|
+
* @param ctx
|
|
883
|
+
* @returns
|
|
884
884
|
*/
|
|
885
885
|
const getSession = (ctx) => {
|
|
886
886
|
if (!isRecord(ctx)) return;
|
package/dist/setup.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { L as Response$1, a as kanunSessionPlugin, i as arkstackHttpPlugin, j as old, t as redirect, z as Request$1 } from "./redirect-
|
|
1
|
+
import { L as Response$1, a as kanunSessionPlugin, i as arkstackHttpPlugin, j as old, t as redirect, z as Request$1 } from "./redirect-D4Oybkdd.js";
|
|
2
2
|
import { CoreRouter } from "clear-router";
|
|
3
3
|
import { Validator } from "kanun";
|
|
4
4
|
import { dirname, join } from "node:path";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arkstack/http",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "HTTP module for Arkstack, providing framework-agnostic request and response primitives.",
|
|
6
6
|
"homepage": "https://arkstack.toneflix.net/guide/http",
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"clear-router": "^2.9.3",
|
|
33
33
|
"dotenv": "^17.4.2",
|
|
34
|
-
"@arkstack/contract": "^0.19.
|
|
35
|
-
"@arkstack/common": "^0.19.
|
|
34
|
+
"@arkstack/contract": "^0.19.4",
|
|
35
|
+
"@arkstack/common": "^0.19.4"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
38
|
"arkormx": "^2.12.8",
|