@nano-app/backend 0.12.2 → 0.12.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/build/index.d.ts CHANGED
@@ -4,7 +4,6 @@ import { Options } from "express-rate-limit";
4
4
  import "dotenv/config";
5
5
  import "jiti";
6
6
  import { BetterAuthOptions } from "better-auth";
7
- //#region ../core/types/api.d.ts
8
7
  /** API response */
9
8
  type ApiResponse<T = any> = {
10
9
  status?: number;
@@ -23,8 +22,6 @@ type QueryParams = {
23
22
  orderby?: NanoObject<'asc' | 'desc'>;
24
23
  select?: string;
25
24
  };
26
- //#endregion
27
- //#region ../core/types/objects.d.ts
28
25
  /** Extra params of handlers and callbacks */
29
26
  type Params<DB = any> = Partial<NanoObject & {
30
27
  db?: DB;
@@ -68,8 +65,6 @@ type RouteEntry<DB = any> = {
68
65
  } & Handlers<DB>;
69
66
  /** Generic object */
70
67
  type NanoObject<T = any> = Record<string, T>;
71
- //#endregion
72
- //#region src/types/database.d.ts
73
68
  /** Database client configuration. */
74
69
  type DatabaseConfig = {
75
70
  /** Whether the database is enabled. Defaults to false */
@@ -77,8 +72,6 @@ type DatabaseConfig = {
77
72
  /** Prisma schema file (`.prisma`), relative to `cwd` */
78
73
  schemaPath: string;
79
74
  };
80
- //#endregion
81
- //#region src/types/plugin.d.ts
82
75
  /** When a plugin is mounted, relative to the consumer routes */
83
76
  type PluginStage = 'before' | 'after';
84
77
  /** Plugin configuration: a group of endpoints */
@@ -116,8 +109,6 @@ type MainPluginConfig<Options = NanoObject> = {
116
109
  /** Plugin callbacks */
117
110
  callbacks?: PluginCallbacks;
118
111
  };
119
- //#endregion
120
- //#region src/types/app.d.ts
121
112
  /** Configuration of the framework's built-in packages */
122
113
  type PackagesConfig = {
123
114
  /** Morgan configuration */
@@ -157,14 +148,10 @@ type NanoAppConfig = {
157
148
  /** Main plugin to mount. */
158
149
  mainPlugin?: MainPluginConfig;
159
150
  };
160
- //#endregion
161
- //#region src/app/config.d.ts
162
151
  /** Merges the consumer configuration over the initial one; the main plugin is always named "app" */
163
152
  declare function mergeConfig(oConfig?: NanoAppConfig): NanoAppConfig & Required<Pick<NanoAppConfig, 'settings' | 'plugins' | 'packages'>> & {
164
153
  mainPlugin: PluginConfig;
165
154
  };
166
- //#endregion
167
- //#region src/app/NanoApp.d.ts
168
155
  /** Main NanoApp class */
169
156
  declare class NanoApp {
170
157
  protected oApp: Express;
@@ -177,8 +164,6 @@ declare class NanoApp {
177
164
  /** Adds the packages according to the configuration */
178
165
  private setPackages;
179
166
  }
180
- //#endregion
181
- //#region src/app/creators.d.ts
182
167
  /** Creates a new NanoApp instance */
183
168
  export declare function createNanoApp(oConfig?: NanoAppConfig): NanoApp;
184
169
  /** Creates and types a route object. */
@@ -188,5 +173,4 @@ type Creator<Options> = (options?: Options) => PluginConfig<Options>;
188
173
  export declare function createPlugin<Options>(fnCreator: Creator<Options>): Creator<Options>;
189
174
  /** Creates and types the callbacks of a plugin. */
190
175
  export declare function createPluginCallbacks<DB>(oCallbacks: PluginCallbacks<DB>): PluginCallbacks<DB>;
191
- //#endregion
192
176
  export { type ApiPromise, type ApiResponse, type Callbacks, type DatabaseConfig, type Handler, type Handlers, type MainPluginConfig, NanoApp, type NanoAppConfig, type NanoObject, type PackagesConfig, type Params, type PluginCallbacks, type PluginConfig, type PluginStage, type QueryParams, type Request, type RouteEntry };
package/build/index.js CHANGED
@@ -12,7 +12,7 @@ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
12
12
  import { createJiti } from "jiti";
13
13
  import { execFileSync } from "node:child_process";
14
14
  import { createHash } from "node:crypto";
15
- //#region ../core/const.ts
15
+ // ../core/const.ts
16
16
  /** HTTP methods a route can handle */
17
17
  const HTTP_METHODS = [
18
18
  "GET",
@@ -25,8 +25,7 @@ const HTTP_METHODS = [
25
25
  const OFFICIAL_PLUGINS = "@nano-app/plugins";
26
26
  /** Error when the database URL is missing at startup */
27
27
  const MISSING_DATABASE_URL = "[nano-app] [ERROR] The DATABASE_URL environment variable is not defined.";
28
- //#endregion
29
- //#region ../core/loader/Validator.ts
28
+ // ../core/loader/Validator.ts
30
29
  const STORE_TYPES = ["app", "api"];
31
30
  /** Checks the consumer's files: invalid ones are warned about and discarded */
32
31
  var Validator = class Validator {
@@ -83,8 +82,7 @@ var Validator = class Validator {
83
82
  return this.oValidators[sExtension]?.()(oEntry, sFilePath) ? oEntry : void 0;
84
83
  }
85
84
  };
86
- //#endregion
87
- //#region ../core/loader/FileReader.ts
85
+ // ../core/loader/FileReader.ts
88
86
  /** Reads and loads files from disk, resolved from `cwd` */
89
87
  var FileReader = class {
90
88
  /** Loader of the consumer's modules; the Prisma runtime is loaded natively */
@@ -110,8 +108,7 @@ var FileReader = class {
110
108
  return sAbsolutePath;
111
109
  }
112
110
  };
113
- //#endregion
114
- //#region ../core/utils/Formatter.ts
111
+ // ../core/utils/Formatter.ts
115
112
  /** Formats values for logs and messages */
116
113
  var Formatter = class {
117
114
  /** Message of anything thrown: its `message` when it has one, else the value itself */
@@ -124,8 +121,7 @@ var Formatter = class {
124
121
  return oDate.toISOString().slice(0, 19).replace("T", " ");
125
122
  }
126
123
  };
127
- //#endregion
128
- //#region ../core/loader/FileLoader.ts
124
+ // ../core/loader/FileLoader.ts
129
125
  /** Finds, loads and validates the consumer's files */
130
126
  var FileLoader = class {
131
127
  /**
@@ -157,8 +153,7 @@ var FileLoader = class {
157
153
  return Validator.validate(oEntries, extension);
158
154
  }
159
155
  };
160
- //#endregion
161
- //#region src/routes/Endpoint.ts
156
+ // src/routes/Endpoint.ts
162
157
  /** Base class for all endpoints */
163
158
  var Endpoint = class {
164
159
  oMethods;
@@ -201,8 +196,7 @@ var Endpoint = class {
201
196
  };
202
197
  }
203
198
  };
204
- //#endregion
205
- //#region src/routes/Router.ts
199
+ // src/routes/Router.ts
206
200
  /** Turns a folder of `*.route.ts` files into Express paths and endpoints */
207
201
  var Router = class {
208
202
  oRoutes = {};
@@ -232,8 +226,7 @@ var Router = class {
232
226
  return `${this.sBasePath}${sEndpoint.replace(/\/index$/, "")}${sExpression}` || "/";
233
227
  }
234
228
  };
235
- //#endregion
236
- //#region src/auth/BetterAuth.ts
229
+ // src/auth/BetterAuth.ts
237
230
  /** Better Auth on the app's Prisma client: the instance, its handler and a session guard */
238
231
  var BetterAuth = class {
239
232
  /** Creates the instance on the app's client, its handler and the guard */
@@ -265,8 +258,7 @@ var BetterAuth = class {
265
258
  };
266
259
  }
267
260
  };
268
- //#endregion
269
- //#region src/database/Prisma.ts
261
+ // src/database/Prisma.ts
270
262
  /** Runs the consumer's Prisma CLI: generates clients and applies official plugins' migrations */
271
263
  var Prisma = class {
272
264
  /** Folder of a client and its files, in the project */
@@ -341,8 +333,7 @@ var Prisma = class {
341
333
  }
342
334
  }
343
335
  };
344
- //#endregion
345
- //#region src/database/Database.ts
336
+ // src/database/Database.ts
346
337
  /** Prisma clients of the app and its plugins, one per name */
347
338
  var Database = class {
348
339
  static oAdapter;
@@ -401,8 +392,7 @@ var Database = class {
401
392
  return JSON.parse(readFileSync(join(sDir, "package.json"), "utf-8")).name === OFFICIAL_PLUGINS;
402
393
  }
403
394
  };
404
- //#endregion
405
- //#region src/routes/Plugin.ts
395
+ // src/routes/Plugin.ts
406
396
  /** A group of routes, with its options, callbacks and database */
407
397
  var Plugin = class {
408
398
  oConfig;
@@ -431,8 +421,7 @@ var Plugin = class {
431
421
  for (const { path, endpoint } of await oRouter.mount()) oApp.all(path, await endpoint.mount(oParams));
432
422
  }
433
423
  };
434
- //#endregion
435
- //#region src/app/config.ts
424
+ // src/app/config.ts
436
425
  /** Initial application configuration */
437
426
  const INITIAL_CONFIG = {
438
427
  /** Application port */
@@ -510,8 +499,7 @@ function mergeConfig(oConfig = {}) {
510
499
  }
511
500
  };
512
501
  }
513
- //#endregion
514
- //#region src/app/errors.ts
502
+ // src/app/errors.ts
515
503
  /** Whether anything thrown is an object, read as a HandlerError */
516
504
  function isHandlerError(oError) {
517
505
  return typeof oError === "object" && oError !== null;
@@ -548,8 +536,7 @@ const errorHandler = (oError, _oReq, oRes, _fnNext) => {
548
536
  if (status >= 500) console.error("[nano-app] [ERROR]", oError);
549
537
  oRes.status(status).json(body);
550
538
  };
551
- //#endregion
552
- //#region src/app/NanoApp.ts
539
+ // src/app/NanoApp.ts
553
540
  /** Main NanoApp class */
554
541
  var NanoApp = class {
555
542
  oApp;
@@ -603,8 +590,7 @@ var NanoApp = class {
603
590
  if (oConfig.urlencoded) this.oApp.use(express.urlencoded(oConfig.urlencoded));
604
591
  }
605
592
  };
606
- //#endregion
607
- //#region src/app/creators.ts
593
+ // src/app/creators.ts
608
594
  /** Creates a new NanoApp instance */
609
595
  function createNanoApp(oConfig) {
610
596
  return new NanoApp(oConfig);
@@ -620,5 +606,4 @@ function createPlugin(fnCreator) {
620
606
  function createPluginCallbacks(oCallbacks) {
621
607
  return oCallbacks;
622
608
  }
623
- //#endregion
624
609
  export { NanoApp, createNanoApp, createPlugin, createPluginCallbacks, createRoute };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nano-app/backend",
3
- "version": "0.12.2",
3
+ "version": "0.12.4",
4
4
  "description": "Express server with file-convention routes, plugins and an optional PostgreSQL layer",
5
5
  "type": "module",
6
6
  "main": "build/index.js",
@@ -47,8 +47,8 @@
47
47
  "cors": "^2.8.6",
48
48
  "dotenv": "^18.0.9",
49
49
  "express": "^5.3.0",
50
- "express-rate-limit": "^8.7.1",
51
- "glob": "^13.0.6",
50
+ "express-rate-limit": "^8.7.2",
51
+ "glob": "^14.0.3",
52
52
  "helmet": "^8.3.0",
53
53
  "jiti": "^2.7.0",
54
54
  "morgan": "^1.12.1"
@@ -56,7 +56,7 @@
56
56
  "peerDependencies": {
57
57
  "@prisma/adapter-pg": "^7.10.1",
58
58
  "@prisma/client": "^7.10.1",
59
- "better-auth": "^1.7.12",
59
+ "better-auth": "^1.7.15",
60
60
  "pg": "^8.23.1"
61
61
  },
62
62
  "peerDependenciesMeta": {
@@ -80,12 +80,12 @@
80
80
  "@types/cors": "^2.8.19",
81
81
  "@types/express": "^5.0.6",
82
82
  "@types/morgan": "^1.9.10",
83
- "@types/node": "^26.6.5",
83
+ "@types/node": "^26.6.6",
84
84
  "@types/pg": "^8.20.0",
85
- "better-auth": "^1.7.12",
85
+ "better-auth": "^1.7.15",
86
86
  "pg": "^8.23.1",
87
87
  "prisma": "^7.10.1",
88
- "tsdown": "^0.23.1",
88
+ "tsdown": "^0.23.4",
89
89
  "tsx": "^4.23.15",
90
90
  "typescript": "^7.0.2"
91
91
  }