skyguard-js 1.2.3 → 1.2.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 +1 -14
- package/dist/http/nodeNativeHttp.d.ts +1 -0
- package/dist/http/nodeNativeHttp.js +14 -3
- package/dist/http/response.js +2 -2
- package/dist/sessions/cookies.js +6 -6
- package/package.json +9 -10
package/README.md
CHANGED
|
@@ -40,6 +40,7 @@ Skyguard.js currently delivers a solid core that includes **routing**, **type-sa
|
|
|
40
40
|
- File uploads (via middleware)
|
|
41
41
|
- Static file serving
|
|
42
42
|
- Session handling (via middleware)
|
|
43
|
+
- Supported runtimes: [Bun](https://bun.com/) and [Deno](https://deno.com/)
|
|
43
44
|
|
|
44
45
|
---
|
|
45
46
|
|
|
@@ -89,20 +90,6 @@ Full documentation is available on the [Official Website](https://pipe930.github
|
|
|
89
90
|
|
|
90
91
|
---
|
|
91
92
|
|
|
92
|
-
## 🔮 Roadmap (Tentative)
|
|
93
|
-
|
|
94
|
-
- Middleware system (✅)
|
|
95
|
-
- Template engines supported (✅)
|
|
96
|
-
- Context abstraction (✅)
|
|
97
|
-
- Data validation (✅)
|
|
98
|
-
- Error handling improvements (✅)
|
|
99
|
-
- Sessions & cookies (✅)
|
|
100
|
-
- Passoword hashing & JWT tokens (✅)
|
|
101
|
-
- File uploads (✅)
|
|
102
|
-
- Database & ORM integration
|
|
103
|
-
- Authentication & authorization
|
|
104
|
-
- WebSockets
|
|
105
|
-
|
|
106
93
|
## 📜 License
|
|
107
94
|
|
|
108
95
|
Licensed under the [MIT License](https://github.com/Pipe930/Skyguard-js/blob/main/LICENSE).
|
|
@@ -42,12 +42,13 @@ class NodeHttpAdapter {
|
|
|
42
42
|
* @returns A fully constructed {@link Context} instance
|
|
43
43
|
*/
|
|
44
44
|
async getContext() {
|
|
45
|
-
const
|
|
45
|
+
const protocol = this.getProtocol();
|
|
46
|
+
const url = new URL(this.req.url ?? "/", `${protocol}://${this.req.headers.host}`);
|
|
46
47
|
const request = new request_1.Request(url.pathname);
|
|
47
|
-
request.setMethod(this.req.method
|
|
48
|
+
request.setMethod(this.req.method ?? httpMethods_1.HttpMethods.get);
|
|
48
49
|
request.setQuery(Object.fromEntries(url.searchParams.entries()));
|
|
49
50
|
request.setHeaders(this.req.headers);
|
|
50
|
-
request.setRemoteAddress(this.req.socket
|
|
51
|
+
request.setRemoteAddress(this.req.socket.remoteAddress);
|
|
51
52
|
if (request.method === httpMethods_1.HttpMethods.post ||
|
|
52
53
|
request.method === httpMethods_1.HttpMethods.put ||
|
|
53
54
|
request.method === httpMethods_1.HttpMethods.patch) {
|
|
@@ -81,5 +82,15 @@ class NodeHttpAdapter {
|
|
|
81
82
|
}
|
|
82
83
|
this.res.end(response.content);
|
|
83
84
|
}
|
|
85
|
+
getProtocol() {
|
|
86
|
+
const forwarded = this.req.headers["x-forwarded-proto"];
|
|
87
|
+
if (typeof forwarded === "string") {
|
|
88
|
+
return forwarded.split(",")[0].trim();
|
|
89
|
+
}
|
|
90
|
+
if (this.req.socket.encrypted) {
|
|
91
|
+
return "https";
|
|
92
|
+
}
|
|
93
|
+
return "http";
|
|
94
|
+
}
|
|
84
95
|
}
|
|
85
96
|
exports.NodeHttpAdapter = NodeHttpAdapter;
|
package/dist/http/response.js
CHANGED
|
@@ -71,7 +71,7 @@ class Response {
|
|
|
71
71
|
/**
|
|
72
72
|
* Sets a cookie in the `Set-Cookie` response header.
|
|
73
73
|
*/
|
|
74
|
-
setCookie(name, value, options
|
|
74
|
+
setCookie(name, value, options) {
|
|
75
75
|
const cookie = (0, cookies_1.serializeCookie)(name, value, options);
|
|
76
76
|
const current = this._headers["Set-Cookie"];
|
|
77
77
|
if (!current) {
|
|
@@ -88,7 +88,7 @@ class Response {
|
|
|
88
88
|
/**
|
|
89
89
|
* Clears a cookie by setting an empty value and immediate expiration.
|
|
90
90
|
*/
|
|
91
|
-
removeCookie(name, options
|
|
91
|
+
removeCookie(name, options) {
|
|
92
92
|
return this.setCookie(name, "", {
|
|
93
93
|
...options,
|
|
94
94
|
maxAge: 0,
|
package/dist/sessions/cookies.js
CHANGED
|
@@ -57,17 +57,17 @@ function parseCookies(cookieHeader) {
|
|
|
57
57
|
*
|
|
58
58
|
* @returns A properly formatted `Set-Cookie` header string.
|
|
59
59
|
*/
|
|
60
|
-
function serializeCookie(name, value, options
|
|
60
|
+
function serializeCookie(name, value, options) {
|
|
61
61
|
const parts = [`${name}=${encodeURIComponent(value)}`];
|
|
62
|
-
if (typeof options
|
|
62
|
+
if (typeof options?.maxAge === "number")
|
|
63
63
|
parts.push(`Max-Age=${options.maxAge}`);
|
|
64
|
-
if (options
|
|
64
|
+
if (options?.path)
|
|
65
65
|
parts.push(`Path=${options.path}`);
|
|
66
|
-
if (options
|
|
66
|
+
if (options?.sameSite)
|
|
67
67
|
parts.push(`SameSite=${options.sameSite}`);
|
|
68
|
-
if (options
|
|
68
|
+
if (options?.httpOnly)
|
|
69
69
|
parts.push("HttpOnly");
|
|
70
|
-
if (options
|
|
70
|
+
if (options?.secure)
|
|
71
71
|
parts.push("Secure");
|
|
72
72
|
return parts.join("; ");
|
|
73
73
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "skyguard-js",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.4",
|
|
4
4
|
"description": "A lightweight, dependency-free TypeScript backend framework",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -57,18 +57,17 @@
|
|
|
57
57
|
"license": "MIT",
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@eslint/js": "10.0.1",
|
|
60
|
-
"@jest/globals": "30.
|
|
60
|
+
"@jest/globals": "30.3.0",
|
|
61
61
|
"@types/jest": "30.0.0",
|
|
62
|
-
"@types/node": "25.
|
|
63
|
-
"eslint": "10.0
|
|
62
|
+
"@types/node": "25.6.0",
|
|
63
|
+
"eslint": "10.2.0",
|
|
64
64
|
"eslint-config-prettier": "10.1.8",
|
|
65
|
-
"globals": "17.
|
|
66
|
-
"jest": "30.
|
|
65
|
+
"globals": "17.5.0",
|
|
66
|
+
"jest": "30.3.0",
|
|
67
67
|
"nodemon": "3.1.14",
|
|
68
|
-
"
|
|
69
|
-
"ts-jest": "29.4.6",
|
|
68
|
+
"ts-jest": "29.4.9",
|
|
70
69
|
"ts-node": "10.9.2",
|
|
71
|
-
"typescript": "
|
|
72
|
-
"typescript-eslint": "8.
|
|
70
|
+
"typescript": "6.0.2",
|
|
71
|
+
"typescript-eslint": "8.58.2"
|
|
73
72
|
}
|
|
74
73
|
}
|