@lolyjs/core 0.2.0-alpha.14 → 0.2.0-alpha.16

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/dist/index.d.mts CHANGED
@@ -1,10 +1,11 @@
1
1
  import http from 'http';
2
- import { Request, Response } from 'express';
3
- import { Socket, Server } from 'socket.io';
4
- export { c as bootstrapClient } from './bootstrap-DgvWWDim.mjs';
2
+ export { a as ApiContext, A as ApiMiddleware, G as GenerateStaticParams, L as LoaderResult, M as MetadataLoader, R as RouteMiddleware, S as ServerContext, b as ServerLoader, W as WssContext } from './index.types-BPX6IVAC.mjs';
3
+ export { c as bootstrapClient } from './bootstrap-BfGTMUkj.mjs';
5
4
  import { ZodSchema, z } from 'zod';
6
5
  import * as express_rate_limit from 'express-rate-limit';
7
6
  import pino, { Logger as Logger$1 } from 'pino';
7
+ import { Request, Response } from 'express';
8
+ import 'socket.io';
8
9
 
9
10
  /**
10
11
  * Framework configuration interface.
@@ -63,6 +64,7 @@ declare const DEFAULT_CONFIG: FrameworkConfig;
63
64
  *
64
65
  * @param projectRoot - Root directory of the project
65
66
  * @returns Framework configuration
67
+ * @throws ConfigValidationError if configuration is invalid
66
68
  */
67
69
  declare function loadConfig(projectRoot: string): FrameworkConfig;
68
70
  /**
@@ -119,77 +121,6 @@ interface InitServerData {
119
121
  server: http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
120
122
  }
121
123
 
122
- type GenerateStaticParams = () => Array<Record<string, string>> | Promise<Array<Record<string, string>>>;
123
- interface ServerContext {
124
- req: Request;
125
- res: Response;
126
- params: Record<string, string>;
127
- pathname: string;
128
- locals: Record<string, any>;
129
- }
130
- interface WssActions {
131
- /**
132
- * Emit an event to all clients in the namespace
133
- */
134
- emit: (event: string, ...args: any[]) => void;
135
- /**
136
- * Emit an event to a specific socket by Socket.IO socket ID
137
- */
138
- emitTo: (socketId: string, event: string, ...args: any[]) => void;
139
- /**
140
- * Emit an event to a specific client by custom clientId
141
- * Requires clientId to be stored in socket.data.clientId during connection
142
- */
143
- emitToClient: (clientId: string, event: string, ...args: any[]) => void;
144
- /**
145
- * Broadcast an event to all clients in the namespace except the sender
146
- */
147
- broadcast: (event: string, ...args: any[]) => void;
148
- }
149
- interface WssContext {
150
- socket: Socket;
151
- io: Server;
152
- params: Record<string, string>;
153
- pathname: string;
154
- data?: any;
155
- actions: WssActions;
156
- }
157
- type RouteMiddleware = (ctx: ServerContext & {
158
- theme?: string;
159
- }, next: () => Promise<void>) => Promise<void> | void;
160
- interface LoaderResult {
161
- props?: Record<string, any>;
162
- redirect?: {
163
- destination: string;
164
- permanent?: boolean;
165
- };
166
- notFound?: boolean;
167
- metadata?: PageMetadata | null;
168
- className?: string;
169
- theme?: string;
170
- }
171
- type ServerLoader = (ctx: ServerContext) => Promise<LoaderResult>;
172
- interface PageMetadata {
173
- title?: string;
174
- description?: string;
175
- metaTags?: {
176
- name?: string;
177
- property?: string;
178
- content: string;
179
- }[];
180
- }
181
- type MetadataLoader = (ctx: ServerContext) => PageMetadata | Promise<PageMetadata>;
182
- interface ApiContext {
183
- req: Request;
184
- res: Response;
185
- Response: (body?: any, status?: number) => Response<any, Record<string, any>>;
186
- NotFound: (body?: any) => Response<any, Record<string, any>>;
187
- params: Record<string, string>;
188
- pathname: string;
189
- locals: Record<string, any>;
190
- }
191
- type ApiMiddleware = (ctx: ApiContext, next: () => Promise<void>) => void | Promise<void>;
192
-
193
124
  interface ServerConfig {
194
125
  bodyLimit?: string;
195
126
  corsOrigin?: string | string[] | boolean | ((origin: string | undefined, callback: (err: Error | null, allow?: boolean) => void) => void);
@@ -332,12 +263,15 @@ interface RateLimitConfig {
332
263
  legacyHeaders?: boolean;
333
264
  skipSuccessfulRequests?: boolean;
334
265
  skipFailedRequests?: boolean;
266
+ keyGenerator?: (req: any) => string;
267
+ skip?: (req: any) => boolean;
335
268
  }
336
269
  /**
337
270
  * Creates a rate limiter middleware with configurable options.
338
271
  *
339
272
  * @param config - Rate limiting configuration
340
273
  * @returns Express rate limit middleware
274
+ * @throws Error if configuration is invalid
341
275
  */
342
276
  declare function createRateLimiter(config?: RateLimitConfig): express_rate_limit.RateLimitRequestHandler;
343
277
  /**
@@ -442,4 +376,4 @@ declare function requestLoggerMiddleware(options?: {
442
376
  */
443
377
  declare function getRequestLogger(req: Request): Logger;
444
378
 
445
- export { type ApiContext, type ApiMiddleware, DEFAULT_CONFIG, type FrameworkConfig, type GenerateStaticParams, type InitServerData, type LoaderResult, type LogLevel, Logger, type LoggerContext, type LoggerOptions, type MetadataLoader, type RouteMiddleware, type ServerConfig, type ServerContext, type ServerLoader, ValidationError, type WssContext, buildApp, commonSchemas, createModuleLogger, createRateLimiter, defaultRateLimiter, generateRequestId, getAppDir, getBuildDir, getLogger, getRequestLogger, getStaticDir, lenientRateLimiter, loadConfig, logger, requestLoggerMiddleware, resetLogger, safeValidate, sanitizeObject, sanitizeParams, sanitizeQuery, sanitizeString, setLogger, startDevServer, startProdServer, strictRateLimiter, validate, withCache };
379
+ export { DEFAULT_CONFIG, type FrameworkConfig, type InitServerData, type LogLevel, Logger, type LoggerContext, type LoggerOptions, type ServerConfig, ValidationError, buildApp, commonSchemas, createModuleLogger, createRateLimiter, defaultRateLimiter, generateRequestId, getAppDir, getBuildDir, getLogger, getRequestLogger, getStaticDir, lenientRateLimiter, loadConfig, logger, requestLoggerMiddleware, resetLogger, safeValidate, sanitizeObject, sanitizeParams, sanitizeQuery, sanitizeString, setLogger, startDevServer, startProdServer, strictRateLimiter, validate, withCache };
package/dist/index.d.ts CHANGED
@@ -1,10 +1,11 @@
1
1
  import http from 'http';
2
- import { Request, Response } from 'express';
3
- import { Socket, Server } from 'socket.io';
4
- export { c as bootstrapClient } from './bootstrap-DgvWWDim.js';
2
+ export { a as ApiContext, A as ApiMiddleware, G as GenerateStaticParams, L as LoaderResult, M as MetadataLoader, R as RouteMiddleware, S as ServerContext, b as ServerLoader, W as WssContext } from './index.types-BPX6IVAC.js';
3
+ export { c as bootstrapClient } from './bootstrap-BfGTMUkj.js';
5
4
  import { ZodSchema, z } from 'zod';
6
5
  import * as express_rate_limit from 'express-rate-limit';
7
6
  import pino, { Logger as Logger$1 } from 'pino';
7
+ import { Request, Response } from 'express';
8
+ import 'socket.io';
8
9
 
9
10
  /**
10
11
  * Framework configuration interface.
@@ -63,6 +64,7 @@ declare const DEFAULT_CONFIG: FrameworkConfig;
63
64
  *
64
65
  * @param projectRoot - Root directory of the project
65
66
  * @returns Framework configuration
67
+ * @throws ConfigValidationError if configuration is invalid
66
68
  */
67
69
  declare function loadConfig(projectRoot: string): FrameworkConfig;
68
70
  /**
@@ -119,77 +121,6 @@ interface InitServerData {
119
121
  server: http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
120
122
  }
121
123
 
122
- type GenerateStaticParams = () => Array<Record<string, string>> | Promise<Array<Record<string, string>>>;
123
- interface ServerContext {
124
- req: Request;
125
- res: Response;
126
- params: Record<string, string>;
127
- pathname: string;
128
- locals: Record<string, any>;
129
- }
130
- interface WssActions {
131
- /**
132
- * Emit an event to all clients in the namespace
133
- */
134
- emit: (event: string, ...args: any[]) => void;
135
- /**
136
- * Emit an event to a specific socket by Socket.IO socket ID
137
- */
138
- emitTo: (socketId: string, event: string, ...args: any[]) => void;
139
- /**
140
- * Emit an event to a specific client by custom clientId
141
- * Requires clientId to be stored in socket.data.clientId during connection
142
- */
143
- emitToClient: (clientId: string, event: string, ...args: any[]) => void;
144
- /**
145
- * Broadcast an event to all clients in the namespace except the sender
146
- */
147
- broadcast: (event: string, ...args: any[]) => void;
148
- }
149
- interface WssContext {
150
- socket: Socket;
151
- io: Server;
152
- params: Record<string, string>;
153
- pathname: string;
154
- data?: any;
155
- actions: WssActions;
156
- }
157
- type RouteMiddleware = (ctx: ServerContext & {
158
- theme?: string;
159
- }, next: () => Promise<void>) => Promise<void> | void;
160
- interface LoaderResult {
161
- props?: Record<string, any>;
162
- redirect?: {
163
- destination: string;
164
- permanent?: boolean;
165
- };
166
- notFound?: boolean;
167
- metadata?: PageMetadata | null;
168
- className?: string;
169
- theme?: string;
170
- }
171
- type ServerLoader = (ctx: ServerContext) => Promise<LoaderResult>;
172
- interface PageMetadata {
173
- title?: string;
174
- description?: string;
175
- metaTags?: {
176
- name?: string;
177
- property?: string;
178
- content: string;
179
- }[];
180
- }
181
- type MetadataLoader = (ctx: ServerContext) => PageMetadata | Promise<PageMetadata>;
182
- interface ApiContext {
183
- req: Request;
184
- res: Response;
185
- Response: (body?: any, status?: number) => Response<any, Record<string, any>>;
186
- NotFound: (body?: any) => Response<any, Record<string, any>>;
187
- params: Record<string, string>;
188
- pathname: string;
189
- locals: Record<string, any>;
190
- }
191
- type ApiMiddleware = (ctx: ApiContext, next: () => Promise<void>) => void | Promise<void>;
192
-
193
124
  interface ServerConfig {
194
125
  bodyLimit?: string;
195
126
  corsOrigin?: string | string[] | boolean | ((origin: string | undefined, callback: (err: Error | null, allow?: boolean) => void) => void);
@@ -332,12 +263,15 @@ interface RateLimitConfig {
332
263
  legacyHeaders?: boolean;
333
264
  skipSuccessfulRequests?: boolean;
334
265
  skipFailedRequests?: boolean;
266
+ keyGenerator?: (req: any) => string;
267
+ skip?: (req: any) => boolean;
335
268
  }
336
269
  /**
337
270
  * Creates a rate limiter middleware with configurable options.
338
271
  *
339
272
  * @param config - Rate limiting configuration
340
273
  * @returns Express rate limit middleware
274
+ * @throws Error if configuration is invalid
341
275
  */
342
276
  declare function createRateLimiter(config?: RateLimitConfig): express_rate_limit.RateLimitRequestHandler;
343
277
  /**
@@ -442,4 +376,4 @@ declare function requestLoggerMiddleware(options?: {
442
376
  */
443
377
  declare function getRequestLogger(req: Request): Logger;
444
378
 
445
- export { type ApiContext, type ApiMiddleware, DEFAULT_CONFIG, type FrameworkConfig, type GenerateStaticParams, type InitServerData, type LoaderResult, type LogLevel, Logger, type LoggerContext, type LoggerOptions, type MetadataLoader, type RouteMiddleware, type ServerConfig, type ServerContext, type ServerLoader, ValidationError, type WssContext, buildApp, commonSchemas, createModuleLogger, createRateLimiter, defaultRateLimiter, generateRequestId, getAppDir, getBuildDir, getLogger, getRequestLogger, getStaticDir, lenientRateLimiter, loadConfig, logger, requestLoggerMiddleware, resetLogger, safeValidate, sanitizeObject, sanitizeParams, sanitizeQuery, sanitizeString, setLogger, startDevServer, startProdServer, strictRateLimiter, validate, withCache };
379
+ export { DEFAULT_CONFIG, type FrameworkConfig, type InitServerData, type LogLevel, Logger, type LoggerContext, type LoggerOptions, type ServerConfig, ValidationError, buildApp, commonSchemas, createModuleLogger, createRateLimiter, defaultRateLimiter, generateRequestId, getAppDir, getBuildDir, getLogger, getRequestLogger, getStaticDir, lenientRateLimiter, loadConfig, logger, requestLoggerMiddleware, resetLogger, safeValidate, sanitizeObject, sanitizeParams, sanitizeQuery, sanitizeString, setLogger, startDevServer, startProdServer, strictRateLimiter, validate, withCache };