@server/next 0.48.3 → 0.49.1
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/index.d.ts +265 -257
- package/index.js +2204 -1905
- package/package.json +9 -6
- package/readme.md +12 -10
- package/src/jsx/jsx-runtime.js +14 -12
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@server/next",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.49.1",
|
|
4
4
|
"description": "A fully-fledged web server with routing, file uploads, sessions, static files, schema validation, websockets, testing, etc.",
|
|
5
5
|
"homepage": "https://server-js.com/",
|
|
6
6
|
"repository": "github:franciscop/server-next",
|
|
@@ -14,16 +14,17 @@
|
|
|
14
14
|
],
|
|
15
15
|
"scripts": {
|
|
16
16
|
"build": "bunx tsup src/index.ts --format esm --dts --out-dir . --target node24 --external zod --external @valibot/to-json-schema",
|
|
17
|
-
"
|
|
17
|
+
"postinstall": "mkdir -p node_modules/@server && ln -sfn ../.. node_modules/@server/next",
|
|
18
18
|
"start": "bun test --watch",
|
|
19
|
-
"lint": "npx tsc --noEmit && npx @biomejs/biome lint ./src --
|
|
20
|
-
"
|
|
21
|
-
"test
|
|
19
|
+
"lint": "npm run prettier && npx tsc --noEmit && npx @biomejs/biome lint ./src --error-on-warnings",
|
|
20
|
+
"prettier": "prettier --write ./src",
|
|
21
|
+
"test": "bun test src demo"
|
|
22
22
|
},
|
|
23
23
|
"main": "index.js",
|
|
24
24
|
"type": "module",
|
|
25
25
|
"types": "index.d.ts",
|
|
26
26
|
"files": [
|
|
27
|
+
"index.js",
|
|
27
28
|
"index.d.ts",
|
|
28
29
|
"src/jsx/*.js",
|
|
29
30
|
"src/jsx/jsx-runtime.d.ts"
|
|
@@ -58,7 +59,8 @@
|
|
|
58
59
|
"Authentication": "docs/5. Authentication.md",
|
|
59
60
|
"Testing": "docs/6. Testing.md",
|
|
60
61
|
"Concepts": "docs/7. Concepts.md",
|
|
61
|
-
"
|
|
62
|
+
"Errors": "docs/8. Errors.md",
|
|
63
|
+
"FAQ": "docs/9. FAQ.md"
|
|
62
64
|
},
|
|
63
65
|
"tutorials": "docs/tutorials"
|
|
64
66
|
},
|
|
@@ -73,6 +75,7 @@
|
|
|
73
75
|
"arktype": "^2.2.3",
|
|
74
76
|
"bun": "^1.3.13",
|
|
75
77
|
"check-dts": "^0.8.2",
|
|
78
|
+
"prettier": "^3.9.6",
|
|
76
79
|
"tsup": "^8.5.1",
|
|
77
80
|
"typescript": "^6.0.2",
|
|
78
81
|
"valibot": "^1.4.2",
|
package/readme.md
CHANGED
|
@@ -7,7 +7,7 @@ npm install @server/next
|
|
|
7
7
|
```
|
|
8
8
|
|
|
9
9
|
```js
|
|
10
|
-
import server from
|
|
10
|
+
import server from "@server/next";
|
|
11
11
|
|
|
12
12
|
export default server({ uploads: './uploads' })
|
|
13
13
|
.get('/', () => 'Hello world')
|
|
@@ -15,24 +15,26 @@ export default server({ uploads: './uploads' })
|
|
|
15
15
|
.post('/avatar', (ctx) => ctx.body.avatar.path);
|
|
16
16
|
```
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
File storage comes included, so `uploads` takes a folder path or any bucket. Auth stores nothing of its own: two callbacks put the user wherever you already keep data.
|
|
19
19
|
|
|
20
20
|
```js
|
|
21
|
-
import server, { bucket
|
|
22
|
-
import { createClient } from
|
|
21
|
+
import server, { bucket } from "@server/next";
|
|
22
|
+
import { createClient } from "redis";
|
|
23
23
|
|
|
24
|
-
const redis =
|
|
25
|
-
const uploads = bucket.S3('my-bucket', { id,
|
|
24
|
+
const redis = await createClient({ url }).connect();
|
|
25
|
+
const uploads = bucket.S3('my-bucket', { id, secret });
|
|
26
26
|
|
|
27
27
|
export default server({
|
|
28
28
|
uploads,
|
|
29
29
|
auth: {
|
|
30
|
-
strategy: 'cookie',
|
|
31
30
|
providers: ['github'],
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
onLogin: async (profile) => {
|
|
32
|
+
await redis.set(`user:${profile.id}`, JSON.stringify(profile));
|
|
33
|
+
return profile.id;
|
|
34
|
+
},
|
|
35
|
+
getUser: async (id) => JSON.parse(await redis.get(`user:${id}`)),
|
|
34
36
|
},
|
|
35
37
|
});
|
|
36
38
|
```
|
|
37
39
|
|
|
38
|
-
See the [full documentation](https://
|
|
40
|
+
See the [full documentation](https://server-js.com/documentation).
|
package/src/jsx/jsx-runtime.js
CHANGED
|
@@ -47,18 +47,20 @@ const minifyCss = (str) => {
|
|
|
47
47
|
// squeezed, then put back. Comments go first and unconditionally, so one
|
|
48
48
|
// written inside a string is stripped along with the rest.
|
|
49
49
|
const quoted = [];
|
|
50
|
-
return
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
50
|
+
return (
|
|
51
|
+
str
|
|
52
|
+
.replace(/\/\*[\s\S]*?\*\//g, "")
|
|
53
|
+
.replace(
|
|
54
|
+
/"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'/g,
|
|
55
|
+
(match) => `\0${quoted.push(match) - 1}\0`,
|
|
56
|
+
)
|
|
57
|
+
.replace(/\s+/g, " ")
|
|
58
|
+
// `+` is left out on purpose for `calc(100% + 10px)`
|
|
59
|
+
.replace(/\s*([{}:;,>~])\s*/g, "$1")
|
|
60
|
+
.replace(/;}/g, "}")
|
|
61
|
+
.replace(/\0(\d+)\0/g, (_, i) => quoted[i])
|
|
62
|
+
.trim()
|
|
63
|
+
);
|
|
62
64
|
};
|
|
63
65
|
|
|
64
66
|
// React element detection (safe for custom objects too)
|