@nano-app/backend 0.6.4 → 0.7.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/LICENSE +21 -0
- package/README.md +233 -0
- package/build/index.d.ts +149 -0
- package/build/index.js +544 -0
- package/build/nano-app.js +41 -0
- package/package.json +70 -26
- package/dist/app.d.ts +0 -9
- package/dist/app.js +0 -74
- package/dist/auth/ApiKeys.d.ts +0 -25
- package/dist/auth/ApiKeys.js +0 -146
- package/dist/auth/ApiKeysEndpoint.d.ts +0 -19
- package/dist/auth/ApiKeysEndpoint.js +0 -36
- package/dist/auth/ClientCredentials.d.ts +0 -15
- package/dist/auth/ClientCredentials.js +0 -132
- package/dist/auth/TokenEndpoint.d.ts +0 -5
- package/dist/auth/TokenEndpoint.js +0 -33
- package/dist/http/Endpoint.d.ts +0 -17
- package/dist/http/Endpoint.js +0 -59
- package/dist/http/Router.d.ts +0 -6
- package/dist/http/Router.js +0 -20
- package/dist/index.d.ts +0 -12
- package/dist/index.js +0 -28
- package/dist/odata/Entities.d.ts +0 -10
- package/dist/odata/Entities.js +0 -52
- package/dist/odata/QueryBuilder.d.ts +0 -10
- package/dist/odata/QueryBuilder.js +0 -60
- package/dist/prisma/Client.d.ts +0 -12
- package/dist/prisma/Client.js +0 -34
- package/dist/types/api.d.ts +0 -6
- package/dist/types/api.js +0 -2
- package/dist/types/app.d.ts +0 -29
- package/dist/types/app.js +0 -2
- package/dist/types/odata.d.ts +0 -8
- package/dist/types/odata.js +0 -2
- package/dist/utils/Formatter.d.ts +0 -6
- package/dist/utils/Formatter.js +0 -31
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Cristian Serrano
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
# @nano-app/backend
|
|
2
|
+
|
|
3
|
+
Preconfigured Express server with **file-convention routes** and **plugins**: it mounts the base middlewares, discovers your routes, formats every error as JSON, and groups extra endpoints in plugins.
|
|
4
|
+
|
|
5
|
+
- Node ≥ 20, ESM.
|
|
6
|
+
- Optional PostgreSQL layer through your generated Prisma client. Disabled by default: without it no database code is loaded.
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
npm install @nano-app/backend
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Quick start
|
|
13
|
+
|
|
14
|
+
```
|
|
15
|
+
src/
|
|
16
|
+
├── app.ts
|
|
17
|
+
└── routes/
|
|
18
|
+
├── index.route.ts → /
|
|
19
|
+
├── health.route.ts → /health
|
|
20
|
+
└── service/test.route.ts → /service/test
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
// src/app.ts
|
|
25
|
+
import { createNanoApp } from "@nano-app/backend";
|
|
26
|
+
|
|
27
|
+
createNanoApp({ port: 3000 });
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
// src/routes/health.route.ts
|
|
32
|
+
import { createRoute } from "@nano-app/backend";
|
|
33
|
+
|
|
34
|
+
export default createRoute({
|
|
35
|
+
GET: async () => ({ success: true, result: { status: "ok" } }),
|
|
36
|
+
});
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
[nano-app] [INFO] /
|
|
41
|
+
[nano-app] [INFO] /health
|
|
42
|
+
[nano-app] [INFO] /service/test
|
|
43
|
+
|
|
44
|
+
[nano-app] [INFO] Nano App running on port 3000
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Routes
|
|
48
|
+
|
|
49
|
+
Each `*.route.ts` under `mainPlugin.routesDir` default-exports an object with the HTTP methods it implements. **The file path is the URL** (`index.route.ts` → `/`, `api/users.route.ts` → `/api/users`). `expression` adds parameters:
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
export default createRoute({
|
|
53
|
+
expression: ":id", // → /users/:id
|
|
54
|
+
GET: async req => ({ success: true, result: { id: req.params.id } }),
|
|
55
|
+
DELETE: async req => ({ success: true, message: "Deleted" }),
|
|
56
|
+
});
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Each handler receives `(req, db)` — `db` is the Prisma client when a database is enabled ([Database](#database)) — and returns an `ApiResponse`:
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
type ApiResponse<T> = {
|
|
63
|
+
success?: boolean; // true → HTTP 200, any other value → HTTP 400
|
|
64
|
+
result?: T;
|
|
65
|
+
message?: string;
|
|
66
|
+
warning?: boolean;
|
|
67
|
+
};
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
- Undeclared methods respond `405`.
|
|
71
|
+
- An invalid file is discarded with a warning; the other routes keep working.
|
|
72
|
+
|
|
73
|
+
## Configuration
|
|
74
|
+
|
|
75
|
+
Every option is optional.
|
|
76
|
+
|
|
77
|
+
| Option | Default | Description |
|
|
78
|
+
|---|---|---|
|
|
79
|
+
| `port` | `3000` | Listening port. |
|
|
80
|
+
| `listener` | `() => {}` | Callback once the server is listening. |
|
|
81
|
+
| `settings` | `{}` | Values for `app.set()` (e.g. `{ "trust proxy": 1 }`). |
|
|
82
|
+
| `packages` | see below | Framework base middlewares. |
|
|
83
|
+
| `mainPlugin` | `{ routesDir: "src/routes", basePath: "/" }` | Your routes (`routesDir`, relative to `cwd`), `basePath`, `init` and database: see [Database](#database). |
|
|
84
|
+
| `plugins` | `[]` | Plugins mounted around your routes, in order: see [Plugins](#plugins). |
|
|
85
|
+
|
|
86
|
+
`packages` accepts `morgan`, `cors`, `helmet`, `compression`, `rateLimit`, `express` (`express.json` options) and `urlencoded`. The merge is **per section**: passing one key keeps the others; pass `false`/`undefined` to disable one.
|
|
87
|
+
|
|
88
|
+
```ts
|
|
89
|
+
createNanoApp({
|
|
90
|
+
settings: { "trust proxy": 1 },
|
|
91
|
+
packages: {
|
|
92
|
+
cors: { origin: "https://my-app.com" },
|
|
93
|
+
helmet: false,
|
|
94
|
+
rateLimit: { windowMs: 60_000, max: 120 },
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Database
|
|
100
|
+
|
|
101
|
+
Off until enabled: it loads the Prisma client you generated and passes it to your handlers as their second parameter. **It never modifies your database**: generating the client and migrating are up to you, with the Prisma CLI.
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
npm install @prisma/client @prisma/adapter-pg pg
|
|
105
|
+
npm install -D prisma
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
```prisma
|
|
109
|
+
// src/prisma/schema.prisma
|
|
110
|
+
datasource db {
|
|
111
|
+
provider = "postgresql"
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
generator client {
|
|
115
|
+
provider = "prisma-client"
|
|
116
|
+
output = "./client"
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
model User {
|
|
120
|
+
id Int @id @default(autoincrement())
|
|
121
|
+
email String @unique
|
|
122
|
+
}
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
npx nano-app generate # client in .nano-app/prisma-clients/app (add .nano-app/ to .gitignore)
|
|
127
|
+
npx nano-app push # generate + prisma db push; or any Prisma command: npx nano-app migrate dev …
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
```ts
|
|
131
|
+
// src/app.ts — DATABASE_URL comes from the environment (or a .env file)
|
|
132
|
+
createNanoApp({ mainPlugin: { database: { enabled: true } } });
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
```ts
|
|
136
|
+
// src/routes/users.route.ts
|
|
137
|
+
import { createRoute } from "@nano-app/backend";
|
|
138
|
+
import type { PrismaClient } from "../../.nano-app/prisma-clients/app/generated/client";
|
|
139
|
+
|
|
140
|
+
export default createRoute({
|
|
141
|
+
GET: async (_req, db: PrismaClient) => ({ success: true, result: await db.user.findMany() }),
|
|
142
|
+
});
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
| Option | Default | Description |
|
|
146
|
+
|---|---|---|
|
|
147
|
+
| `mainPlugin.database.enabled` | `false` | Mounts your client at startup. |
|
|
148
|
+
| `mainPlugin.database.schemaPath` | `"src/prisma/schema.prisma"` | The single `.prisma` file the client was generated from; its datasource must be `postgresql`. |
|
|
149
|
+
|
|
150
|
+
- Each key falls back to its default, so `{ enabled: true }` is enough with the default layout. The client is always read from `.nano-app/prisma-clients/app/`, where `nano-app generate` writes it.
|
|
151
|
+
- Startup fails if `DATABASE_URL` is missing or the client cannot be loaded or is not a valid PostgreSQL Prisma client. The connection opens on the first query.
|
|
152
|
+
- The `nano_` prefix is reserved for the framework's plugins: a datasource schema starting with it fails the startup.
|
|
153
|
+
- Annotate `db` with your generated `PrismaClient` to type it; otherwise it is `any`, and without an enabled database `undefined`.
|
|
154
|
+
- For several PostgreSQL schemas, declare `schemas = ["public", "billing"]` in the datasource and `@@schema("billing")` on each model; one client covers them all.
|
|
155
|
+
|
|
156
|
+
## Plugins
|
|
157
|
+
|
|
158
|
+
A plugin is a group of endpoints mounted under a base path. Your routes are mounted as one (named `app`). This package ships no official plugin. You write one with `createPlugin` and list it in `plugins`. Nothing is mounted unless you list it.
|
|
159
|
+
|
|
160
|
+
```ts
|
|
161
|
+
// src/plugins/hello/index.ts
|
|
162
|
+
import { createPlugin } from "@nano-app/backend";
|
|
163
|
+
import { dirname, resolve } from "node:path";
|
|
164
|
+
import { fileURLToPath } from "node:url";
|
|
165
|
+
|
|
166
|
+
export default createPlugin((options?: { basePath?: string }) => ({
|
|
167
|
+
name: "hello",
|
|
168
|
+
basePath: options?.basePath ?? "/hello",
|
|
169
|
+
routesDir: resolve(dirname(fileURLToPath(import.meta.url)), "routes"),
|
|
170
|
+
}));
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
```ts
|
|
174
|
+
// src/plugins/hello/routes/index.route.ts → /hello
|
|
175
|
+
import { createRoute } from "@nano-app/backend";
|
|
176
|
+
|
|
177
|
+
export default createRoute({
|
|
178
|
+
GET: async () => ({ success: true, result: { ok: true } }),
|
|
179
|
+
});
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
```ts
|
|
183
|
+
// src/app.ts
|
|
184
|
+
import { createNanoApp } from "@nano-app/backend";
|
|
185
|
+
import hello from "./plugins/hello";
|
|
186
|
+
|
|
187
|
+
createNanoApp({ plugins: [hello()] });
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
`createPlugin` types the options of that plugin. Each plugin chooses its base path and whether it mounts `before` (default) or `after` your routes.
|
|
191
|
+
|
|
192
|
+
Everything is mounted on one Express application, in this order: base middlewares → `before` plugins → your routes → `after` plugins → 404 → error handler.
|
|
193
|
+
|
|
194
|
+
A plugin with its own Prisma schema is generated by name. `nano-app generate <name>` reads `plugins/<name>/schema.prisma` from this package when the plugin ships inside it. A plugin you keep in your app points `database.schemaPath` at your own file and you generate that client yourself. See [PLUGINS.md](https://github.com/Nano-Nathan/nano-app/blob/main/PLUGINS.md).
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
npx nano-app generate # the app schema (src/prisma/schema.prisma) → .nano-app/prisma-clients/app
|
|
198
|
+
npx nano-app push # generate + prisma db push
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
## Errors
|
|
202
|
+
|
|
203
|
+
The framework mounts the 404 and the error handler: an unmatched request becomes a `404`, and anything a handler throws becomes an `ApiResponse`.
|
|
204
|
+
|
|
205
|
+
```ts
|
|
206
|
+
throw { status: 409, message: "Already exists" }; // → 409 { success: false, warning: false, message: "Already exists" }
|
|
207
|
+
throw "Field name is required"; // → 400 { success: false, message: "Field name is required" }
|
|
208
|
+
throw new Error("boom"); // → 500, logged to stderr
|
|
209
|
+
GET /unknown // → 404 { success: false, warning: false, message: "/unknown not found" }
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
## Typed creators
|
|
213
|
+
|
|
214
|
+
| Function | Purpose |
|
|
215
|
+
|---|---|
|
|
216
|
+
| `createNanoApp(config?)` | Creates and starts the app. |
|
|
217
|
+
| `createRoute(route)` | Types a route file. |
|
|
218
|
+
| `createPlugin(creator)` | Types a plugin factory and its options. |
|
|
219
|
+
|
|
220
|
+
Also exported: the configuration types (`NanoAppConfig`, `PackagesConfig`, `PluginConfig`, `PluginStage`, `MainPluginConfig`, `DatabaseConfig`), the Express `Request` type and the HTTP contract (`ApiResponse`, `ApiPromise`, `QueryParams`, `RouteEntry`, `Handler`, `Handlers`, `NanoObject`).
|
|
221
|
+
|
|
222
|
+
## Development
|
|
223
|
+
|
|
224
|
+
```bash
|
|
225
|
+
pnpm build # tsup → build/ (ESM + .d.ts)
|
|
226
|
+
pnpm dev # tsup --watch
|
|
227
|
+
pnpm test # node:test against the real server (tsx --test)
|
|
228
|
+
DATABASE_URL=postgres://… pnpm test # also runs the PostgreSQL suite
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
## License
|
|
232
|
+
|
|
233
|
+
MIT — Cristian Serrano.
|
package/build/index.d.ts
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import express, { Express, Request } from 'express';
|
|
2
|
+
export { Request } from 'express';
|
|
3
|
+
import { Options } from 'express-rate-limit';
|
|
4
|
+
import { CorsOptions } from 'cors';
|
|
5
|
+
|
|
6
|
+
/** Database client configuration. */
|
|
7
|
+
type DatabaseConfig = {
|
|
8
|
+
/** Whether the database is enabled. Defaults to false */
|
|
9
|
+
enabled?: boolean;
|
|
10
|
+
/** Prisma schema file (`.prisma`), relative to `cwd` */
|
|
11
|
+
schemaPath: string;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
/** When a plugin is mounted, relative to the consumer routes */
|
|
15
|
+
type PluginStage = "before" | "after";
|
|
16
|
+
/** Plugin configuration: a group of endpoints */
|
|
17
|
+
type PluginConfig = {
|
|
18
|
+
/** Name of the plugin, same as his database (If have one) */
|
|
19
|
+
name: string;
|
|
20
|
+
/** Directory used to discover the `*.route.ts` files */
|
|
21
|
+
routesDir: string;
|
|
22
|
+
/** Base path prepended to every endpoint of the plugin. Defaults to "/" */
|
|
23
|
+
basePath?: string;
|
|
24
|
+
/** Mount point relative to the consumer routes. Defaults to "before" */
|
|
25
|
+
stage?: PluginStage;
|
|
26
|
+
/** Prisma client the plugin needs, mounted before its endpoints */
|
|
27
|
+
database?: DatabaseConfig;
|
|
28
|
+
/** Callback run first, before the endpoints are mounted */
|
|
29
|
+
init?: (app: Express, db: any) => void | Promise<void>;
|
|
30
|
+
};
|
|
31
|
+
/** The project's plugin: nano-app names it "app" and mounts it between the "before" and "after" plugins */
|
|
32
|
+
type MainPluginConfig = {
|
|
33
|
+
/** Directory of the project's `*.route.ts` files. Defaults to "src/routes" */
|
|
34
|
+
routesDir?: string;
|
|
35
|
+
/** Base path prepended to every route. Defaults to "/" */
|
|
36
|
+
basePath?: string;
|
|
37
|
+
/** The project's database */
|
|
38
|
+
database?: {
|
|
39
|
+
/** Whether the database is enabled. Defaults to false */
|
|
40
|
+
enabled?: boolean;
|
|
41
|
+
/** Prisma schema file, relative to `cwd`. Defaults to "src/prisma/schema.prisma" */
|
|
42
|
+
schemaPath?: string;
|
|
43
|
+
};
|
|
44
|
+
/** Callback run first, before the routes are mounted */
|
|
45
|
+
init?: (app: Express, db: any) => void | Promise<void>;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/** Configuration of the framework's built-in packages */
|
|
49
|
+
type PackagesConfig = {
|
|
50
|
+
/** Morgan configuration */
|
|
51
|
+
morgan?: {
|
|
52
|
+
/** Morgan tokens */
|
|
53
|
+
tokens?: Record<string, any>;
|
|
54
|
+
/** Morgan format */
|
|
55
|
+
format: string;
|
|
56
|
+
};
|
|
57
|
+
/** CORS configuration */
|
|
58
|
+
cors?: CorsOptions;
|
|
59
|
+
/** Helmet configuration */
|
|
60
|
+
helmet?: boolean;
|
|
61
|
+
/** Compression configuration */
|
|
62
|
+
compression?: boolean;
|
|
63
|
+
/** Rate-limit configuration */
|
|
64
|
+
rateLimit?: Partial<Options>;
|
|
65
|
+
/** express.json configuration */
|
|
66
|
+
express?: Partial<Parameters<typeof express.json>[0]>;
|
|
67
|
+
/** urlencoded configuration */
|
|
68
|
+
urlencoded?: Partial<Parameters<typeof express.urlencoded>[0]>;
|
|
69
|
+
};
|
|
70
|
+
/** Application configuration */
|
|
71
|
+
type NanoAppConfig = {
|
|
72
|
+
/** Listener run once the server is listening */
|
|
73
|
+
listener?: () => void;
|
|
74
|
+
/** Application port. Defaults to 3000 */
|
|
75
|
+
port?: number;
|
|
76
|
+
/** Values applied with Express `app.set()` (e.g. `{ "trust proxy": 1 }`) */
|
|
77
|
+
settings?: Record<string, unknown>;
|
|
78
|
+
/** Default middlewares configuration */
|
|
79
|
+
packages?: PackagesConfig;
|
|
80
|
+
/** Plugins to mount. Defaults to [] */
|
|
81
|
+
plugins?: PluginConfig[];
|
|
82
|
+
/** Main plugin to mount. */
|
|
83
|
+
mainPlugin?: MainPluginConfig;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
/** API response */
|
|
87
|
+
type ApiResponse<T = any> = {
|
|
88
|
+
success?: boolean;
|
|
89
|
+
result?: T;
|
|
90
|
+
message?: string;
|
|
91
|
+
warning?: boolean;
|
|
92
|
+
};
|
|
93
|
+
type ApiPromise<T = any> = Promise<{
|
|
94
|
+
success?: boolean;
|
|
95
|
+
result?: T;
|
|
96
|
+
message?: string;
|
|
97
|
+
warning?: boolean;
|
|
98
|
+
}>;
|
|
99
|
+
/** Query parameters sent in the `query` header (JSON). */
|
|
100
|
+
type QueryParams = {
|
|
101
|
+
skip?: number;
|
|
102
|
+
top?: number;
|
|
103
|
+
filter?: NanoObject;
|
|
104
|
+
orderby?: Record<string, "asc" | "desc">;
|
|
105
|
+
select?: string;
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
/** Endpoint method: receives the request and, when the plugin has one, its Prisma client */
|
|
109
|
+
type Handler = (req: Request, db?: any) => ApiPromise;
|
|
110
|
+
type Handlers = {
|
|
111
|
+
GET?: Handler;
|
|
112
|
+
POST?: Handler;
|
|
113
|
+
PUT?: Handler;
|
|
114
|
+
DELETE?: Handler;
|
|
115
|
+
};
|
|
116
|
+
/** Entry of a route file (`*.route.ts`) */
|
|
117
|
+
type RouteEntry = {
|
|
118
|
+
expression?: string;
|
|
119
|
+
} & Handlers;
|
|
120
|
+
type NanoObject<T = any> = Record<string, T>;
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Merges the consumer configuration with the initial one.
|
|
124
|
+
*/
|
|
125
|
+
declare function mergeConfig(config?: NanoAppConfig): NanoAppConfig & {
|
|
126
|
+
mainPlugin: PluginConfig;
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
/** Main NanoApp class */
|
|
130
|
+
declare class NanoApp {
|
|
131
|
+
protected app: Express;
|
|
132
|
+
protected config: ReturnType<typeof mergeConfig>;
|
|
133
|
+
constructor(config?: NanoAppConfig);
|
|
134
|
+
/** Starts the application */
|
|
135
|
+
private start;
|
|
136
|
+
/** Initializes the application in the right order */
|
|
137
|
+
private initialize;
|
|
138
|
+
private setPackages;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/** Creates a new NanoApp instance */
|
|
142
|
+
declare function createNanoApp(config?: NanoAppConfig): NanoApp;
|
|
143
|
+
/** Creates and types a route object. */
|
|
144
|
+
declare function createRoute(route: RouteEntry): RouteEntry;
|
|
145
|
+
/** Creates a plugin: a function of the plugin's own options that returns its configuration. */
|
|
146
|
+
type Creator<Options> = (options?: Options) => PluginConfig;
|
|
147
|
+
declare function createPlugin<Options>(creator: Creator<Options>): Creator<Options>;
|
|
148
|
+
|
|
149
|
+
export { type ApiPromise, type ApiResponse, type DatabaseConfig, type Handler, type Handlers, type MainPluginConfig, NanoApp, type NanoAppConfig, type NanoObject, type PackagesConfig, type PluginConfig, type PluginStage, type QueryParams, type RouteEntry, createNanoApp, createPlugin, createRoute };
|