express-file-cluster 0.3.5 → 0.3.6

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.
@@ -23,6 +23,10 @@ interface EFCConfig {
23
23
  databaseUrl?: string;
24
24
  authStrategy?: AuthStrategy;
25
25
  jwtSecret?: string;
26
+ /** JWT lifetime, e.g. '15m', '1h', '7d'. Default: '7d'. */
27
+ jwtExpiresIn?: string;
28
+ /** Cookie domain for the 'http-only' auth strategy. Default: unset (host-only cookie). */
29
+ cookieDomain?: string;
26
30
  cluster?: boolean;
27
31
  workers?: number;
28
32
  tasks?: TaskConfig | false;
@@ -70,19 +74,36 @@ interface TaskDefinition<TPayload = unknown> {
70
74
  name: string;
71
75
  filePath?: string;
72
76
  }
77
+ /** Primitive field types usable directly, or as the item type of an `array` field via `of`. */
78
+ type PrimitiveFieldType = 'string' | 'number' | 'boolean' | 'date' | 'object' | 'objectId';
73
79
  interface FieldDefinition {
74
- type: 'string' | 'number' | 'boolean' | 'date' | 'object' | 'array';
80
+ type: PrimitiveFieldType | 'array';
75
81
  required?: boolean;
76
82
  unique?: boolean;
77
83
  default?: unknown;
84
+ /** Restricts the field to a fixed set of values. Valid on `string` and `number` types. */
85
+ enum?: readonly (string | number)[];
86
+ /** Mongoose model name to reference. Valid on `objectId` types (bare or as an array's `of`). */
87
+ ref?: string;
88
+ /** Item type for `array` fields, e.g. `{ type: 'array', of: 'string' }`. Omit for an untyped array. */
89
+ of?: PrimitiveFieldType;
90
+ }
91
+ /**
92
+ * A schema field is either a `FieldDefinition`, or a one-element tuple holding a nested
93
+ * `ModelSchema` — the latter defines an array of embedded sub-documents, e.g.:
94
+ * `route_progress: [{ route_id: { type: 'string' } }]`
95
+ */
96
+ type ModelSchema = Record<string, FieldDefinition | [ModelSchema]>;
97
+ interface ModelQueryOptions {
98
+ /** Mongoose `.populate()` path(s) to resolve on `objectId`/ref fields. */
99
+ populate?: string | string[];
78
100
  }
79
- type ModelSchema = Record<string, FieldDefinition>;
80
101
  interface ModelCRUD<T extends Record<string, any>> {
81
- find(filter?: Partial<T>): Promise<T[]>;
82
- findById(id: string): Promise<(T & {
102
+ find(filter?: Partial<T>, options?: ModelQueryOptions): Promise<T[]>;
103
+ findById(id: string, options?: ModelQueryOptions): Promise<(T & {
83
104
  id: string;
84
105
  }) | null>;
85
- findOne(filter: Partial<T>): Promise<(T & {
106
+ findOne(filter: Partial<T>, options?: ModelQueryOptions): Promise<(T & {
86
107
  id: string;
87
108
  }) | null>;
88
109
  create(data: Partial<T>): Promise<T & {
@@ -95,4 +116,4 @@ interface ModelCRUD<T extends Record<string, any>> {
95
116
  count(filter?: Partial<T>): Promise<number>;
96
117
  }
97
118
 
98
- export type { AuthStrategy as A, CorsConfig as C, DatabaseEngine as D, EFCConfig as E, ModelSchema as M, RouteEntry as R, TaskDefinition as T, TaskOptions as a, ModelCRUD as b, RouteMeta as c, RouteMethodMeta as d };
119
+ export type { AuthStrategy as A, CorsConfig as C, DatabaseEngine as D, EFCConfig as E, FieldDefinition as F, ModelSchema as M, RouteEntry as R, TaskDefinition as T, TaskOptions as a, ModelCRUD as b, ModelQueryOptions as c, RouteMeta as d, RouteMethodMeta as e };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "express-file-cluster",
3
- "version": "0.3.5",
3
+ "version": "0.3.6",
4
4
  "description": "Enterprise-grade, zero-boilerplate backend framework with file-based routing and multi-core clustering",
5
5
  "license": "MIT",
6
6
  "type": "module",