@nano-app/plugins 0.1.1 → 0.3.0
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 +9 -5
- package/build/health/index.d.ts +7 -8
- package/build/health/index.js +11 -12
- package/build/health/routes/index.route.js +7 -7
- package/package.json +11 -6
package/README.md
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
# @nano-app/plugins
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/@nano-app/plugins)
|
|
4
|
+
|
|
3
5
|
Official plugins for [`@nano-app/backend`](https://www.npmjs.com/package/@nano-app/backend). One import path per plugin: `@nano-app/plugins/<name>`. Nothing is mounted unless you list it.
|
|
4
6
|
|
|
5
7
|
```bash
|
|
6
|
-
|
|
8
|
+
pnpm add @nano-app/backend @nano-app/plugins
|
|
7
9
|
```
|
|
8
10
|
|
|
9
11
|
```ts
|
|
10
|
-
import { createNanoApp } from
|
|
11
|
-
import
|
|
12
|
+
import { createNanoApp } from '@nano-app/backend';
|
|
13
|
+
import health from '@nano-app/plugins/health';
|
|
12
14
|
|
|
13
15
|
createNanoApp({ plugins: [health()] });
|
|
14
16
|
```
|
|
@@ -17,14 +19,16 @@ createNanoApp({ plugins: [health()] });
|
|
|
17
19
|
|
|
18
20
|
| Plugin | Import | Endpoints | Options |
|
|
19
21
|
|---|---|---|---|
|
|
20
|
-
| `health` | `import
|
|
22
|
+
| `health` | `import health from '@nano-app/plugins/health'` | `GET /health` → `{ status: "ok" }` | `basePath` (default `"/health"`) |
|
|
21
23
|
|
|
22
24
|
## Layout
|
|
23
25
|
|
|
24
26
|
```
|
|
25
27
|
plugins/
|
|
26
28
|
└── <name>/
|
|
27
|
-
├── index.ts exports the
|
|
29
|
+
├── index.ts default-exports the plugin factory: the import path
|
|
30
|
+
├── schema.prisma its tables, when it has any
|
|
31
|
+
├── migrations/ their migrations, applied at startup
|
|
28
32
|
└── routes/ *.route.ts, mounted under the plugin's basePath
|
|
29
33
|
```
|
|
30
34
|
|
package/build/health/index.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
//#region health/index.d.ts
|
|
3
2
|
/** Health check: `GET /health` answers `{ status: "ok" }` while the server is up. */
|
|
4
|
-
declare const
|
|
5
|
-
|
|
6
|
-
} | undefined) =>
|
|
7
|
-
|
|
3
|
+
declare const _default: (options?: {
|
|
4
|
+
basePath?: string;
|
|
5
|
+
} | undefined) => import("@nano-app/backend").PluginConfig<{
|
|
6
|
+
basePath?: string;
|
|
8
7
|
}>;
|
|
9
|
-
|
|
10
|
-
export {
|
|
8
|
+
//#endregion
|
|
9
|
+
export { _default as default };
|
package/build/health/index.js
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
import { dirname, resolve } from "node:path";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
2
3
|
import { createPlugin } from "@nano-app/backend";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
routesDir: resolve(dirname(fileURLToPath(import.meta.url)), "routes")
|
|
4
|
+
//#region health/index.ts
|
|
5
|
+
/** Health check: `GET /health` answers `{ status: "ok" }` while the server is up. */
|
|
6
|
+
var health_default = createPlugin((options) => ({
|
|
7
|
+
name: "health",
|
|
8
|
+
basePath: options?.basePath ?? "/health",
|
|
9
|
+
stage: "before",
|
|
10
|
+
routesDir: resolve(dirname(fileURLToPath(import.meta.url)), "routes")
|
|
11
11
|
}));
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
};
|
|
12
|
+
//#endregion
|
|
13
|
+
export { health_default as default };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
// health/routes/index.route.ts
|
|
2
1
|
import { createRoute } from "@nano-app/backend";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
//#region health/routes/index.route.ts
|
|
3
|
+
var index_route_default = createRoute({ GET: async () => ({
|
|
4
|
+
success: true,
|
|
5
|
+
result: { status: "ok" }
|
|
6
|
+
}) });
|
|
7
|
+
//#endregion
|
|
8
|
+
export { index_route_default as default };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nano-app/plugins",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Official plugins for @nano-app/backend",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"LICENSE"
|
|
15
15
|
],
|
|
16
16
|
"scripts": {
|
|
17
|
-
"build": "
|
|
17
|
+
"build": "tsdown",
|
|
18
18
|
"test": "tsx --env-file-if-exists=../.env --test tests/*.test.ts",
|
|
19
19
|
"prepublishOnly": "pnpm run build"
|
|
20
20
|
},
|
|
@@ -34,17 +34,22 @@
|
|
|
34
34
|
"access": "public"
|
|
35
35
|
},
|
|
36
36
|
"engines": {
|
|
37
|
-
"node": ">=
|
|
37
|
+
"node": ">=22"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
|
-
"@nano-app/backend": ">=0.
|
|
40
|
+
"@nano-app/backend": ">=0.9.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@nano-app/backend": "workspace:*",
|
|
44
|
+
"@prisma/adapter-pg": "^7.10.1",
|
|
45
|
+
"@prisma/client": "^7.10.1",
|
|
44
46
|
"@types/node": "^26.6.5",
|
|
47
|
+
"@types/pg": "^8.23.1",
|
|
45
48
|
"glob": "^13.0.6",
|
|
46
|
-
"
|
|
49
|
+
"pg": "^8.23.1",
|
|
50
|
+
"prisma": "^7.10.1",
|
|
51
|
+
"tsdown": "^0.23.1",
|
|
47
52
|
"tsx": "^4.23.15",
|
|
48
|
-
"typescript": "^
|
|
53
|
+
"typescript": "^7.0.2"
|
|
49
54
|
}
|
|
50
55
|
}
|