maxserver 0.2.1 → 0.2.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.
- package/.github/README.md +6 -1
- package/index.d.ts +14 -0
- package/package.json +1 -1
- package/src/index.js +0 -1
- package/src/setupDocs.js +6 -0
- package/templates/jsconfig.json +31 -0
package/.github/README.md
CHANGED
|
@@ -97,8 +97,9 @@ If you don't want to autoregister some files, then simply don't add that magic c
|
|
|
97
97
|
Files ending with **`.schema.js`** will be auto registered.
|
|
98
98
|
For example: **hello.js** and **hello.schema.js**
|
|
99
99
|
|
|
100
|
+
Schemas are optional.
|
|
100
101
|
Besides the basic validation fields we can set fields like `tags`, `summary` and description,
|
|
101
|
-
which will appear in the docs.
|
|
102
|
+
which will appear in the docs. Only if a schema exists the route will be added to the documentation.
|
|
102
103
|
|
|
103
104
|
|
|
104
105
|
```js
|
|
@@ -217,6 +218,10 @@ Rule of thumb: make the message something you would want to see at 03:00 in logs
|
|
|
217
218
|
|
|
218
219
|
|
|
219
220
|
|
|
221
|
+
## Note
|
|
222
|
+
On loading routes - possible side effects execute.
|
|
223
|
+
Means you can eg declare globals.
|
|
224
|
+
|
|
220
225
|
## About
|
|
221
226
|
- Dependencies: original fastify packages + scalar/fastify-api-reference
|
|
222
227
|
- The source is simple. Everyone can read, understand and modify if needed.
|
package/index.d.ts
CHANGED
|
@@ -5,8 +5,22 @@ declare function maxserver(...args: any[]): any;
|
|
|
5
5
|
export default maxserver;
|
|
6
6
|
|
|
7
7
|
declare global {
|
|
8
|
+
|
|
9
|
+
var global: typeof globalThis;
|
|
10
|
+
|
|
11
|
+
/** Casts a string ID to a MongoDB ObjectId using the global helper [cite: 2026-02-15]. */
|
|
8
12
|
var oid: (id: string) => import("mongodb").ObjectId;
|
|
13
|
+
|
|
14
|
+
/** Access to the global MongoDB database instance [cite: 2026-02-15]. */
|
|
9
15
|
var db: import("mongodb").Db;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Creates an Error object with an attached HTTP status code [cite: 2026-02-15].
|
|
19
|
+
* Fastify catches this to return a structured JSON response.
|
|
20
|
+
* * @param code The HTTP status code (e.g., 400, 401, 403, 404).
|
|
21
|
+
* @param message The specific failure reason returned in the JSON body.
|
|
22
|
+
*/
|
|
23
|
+
var createError: (code: number, message: string) => Error;
|
|
10
24
|
}
|
|
11
25
|
|
|
12
26
|
declare module "fastify" {
|
package/package.json
CHANGED
package/src/index.js
CHANGED
package/src/setupDocs.js
CHANGED
|
@@ -52,6 +52,12 @@ export async function setupDocs(app) {
|
|
|
52
52
|
},
|
|
53
53
|
},
|
|
54
54
|
},
|
|
55
|
+
// Only consider for documentation routes which have a schema
|
|
56
|
+
transform: ({ schema, url }) => {
|
|
57
|
+
const isDefined = schema && (schema.summary || schema.response || schema.body);
|
|
58
|
+
if (!isDefined) return { schema: { hide: true }, url };
|
|
59
|
+
return { schema, url };
|
|
60
|
+
}
|
|
55
61
|
});
|
|
56
62
|
|
|
57
63
|
// not needed, the scalar extension provides it by default on /docs/openapi.json
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"checkJs": true,
|
|
4
|
+
"module": "ES2020",
|
|
5
|
+
"target": "ES2020",
|
|
6
|
+
"moduleResolution": "bundler",
|
|
7
|
+
"jsx": "react-jsx",
|
|
8
|
+
"strict": false,
|
|
9
|
+
"noUnusedParameters": false,
|
|
10
|
+
"noUnusedLocals": false,
|
|
11
|
+
"noImplicitAny": false,
|
|
12
|
+
// new attempt to reduce noise
|
|
13
|
+
"skipLibCheck": true,
|
|
14
|
+
//"baseUrl": ".",
|
|
15
|
+
"paths": {
|
|
16
|
+
"*": [
|
|
17
|
+
"./src/*"
|
|
18
|
+
],
|
|
19
|
+
},
|
|
20
|
+
"types": [
|
|
21
|
+
"node",
|
|
22
|
+
"maxserver"
|
|
23
|
+
]
|
|
24
|
+
},
|
|
25
|
+
"include": [
|
|
26
|
+
"src"
|
|
27
|
+
],
|
|
28
|
+
"exclude": [
|
|
29
|
+
"node_modules",
|
|
30
|
+
],
|
|
31
|
+
}
|