@lolyjs/core 0.2.0-alpha.15 → 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,81 +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
- /**
172
- * Server loader function type (getServerSideProps).
173
- * This function is exported from server.hook.ts files.
174
- */
175
- type ServerLoader = (ctx: ServerContext) => Promise<LoaderResult>;
176
- interface PageMetadata {
177
- title?: string;
178
- description?: string;
179
- metaTags?: {
180
- name?: string;
181
- property?: string;
182
- content: string;
183
- }[];
184
- }
185
- type MetadataLoader = (ctx: ServerContext) => PageMetadata | Promise<PageMetadata>;
186
- interface ApiContext {
187
- req: Request;
188
- res: Response;
189
- Response: (body?: any, status?: number) => Response<any, Record<string, any>>;
190
- NotFound: (body?: any) => Response<any, Record<string, any>>;
191
- params: Record<string, string>;
192
- pathname: string;
193
- locals: Record<string, any>;
194
- }
195
- type ApiMiddleware = (ctx: ApiContext, next: () => Promise<void>) => void | Promise<void>;
196
-
197
124
  interface ServerConfig {
198
125
  bodyLimit?: string;
199
126
  corsOrigin?: string | string[] | boolean | ((origin: string | undefined, callback: (err: Error | null, allow?: boolean) => void) => void);
@@ -336,12 +263,15 @@ interface RateLimitConfig {
336
263
  legacyHeaders?: boolean;
337
264
  skipSuccessfulRequests?: boolean;
338
265
  skipFailedRequests?: boolean;
266
+ keyGenerator?: (req: any) => string;
267
+ skip?: (req: any) => boolean;
339
268
  }
340
269
  /**
341
270
  * Creates a rate limiter middleware with configurable options.
342
271
  *
343
272
  * @param config - Rate limiting configuration
344
273
  * @returns Express rate limit middleware
274
+ * @throws Error if configuration is invalid
345
275
  */
346
276
  declare function createRateLimiter(config?: RateLimitConfig): express_rate_limit.RateLimitRequestHandler;
347
277
  /**
@@ -446,4 +376,4 @@ declare function requestLoggerMiddleware(options?: {
446
376
  */
447
377
  declare function getRequestLogger(req: Request): Logger;
448
378
 
449
- 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,81 +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
- /**
172
- * Server loader function type (getServerSideProps).
173
- * This function is exported from server.hook.ts files.
174
- */
175
- type ServerLoader = (ctx: ServerContext) => Promise<LoaderResult>;
176
- interface PageMetadata {
177
- title?: string;
178
- description?: string;
179
- metaTags?: {
180
- name?: string;
181
- property?: string;
182
- content: string;
183
- }[];
184
- }
185
- type MetadataLoader = (ctx: ServerContext) => PageMetadata | Promise<PageMetadata>;
186
- interface ApiContext {
187
- req: Request;
188
- res: Response;
189
- Response: (body?: any, status?: number) => Response<any, Record<string, any>>;
190
- NotFound: (body?: any) => Response<any, Record<string, any>>;
191
- params: Record<string, string>;
192
- pathname: string;
193
- locals: Record<string, any>;
194
- }
195
- type ApiMiddleware = (ctx: ApiContext, next: () => Promise<void>) => void | Promise<void>;
196
-
197
124
  interface ServerConfig {
198
125
  bodyLimit?: string;
199
126
  corsOrigin?: string | string[] | boolean | ((origin: string | undefined, callback: (err: Error | null, allow?: boolean) => void) => void);
@@ -336,12 +263,15 @@ interface RateLimitConfig {
336
263
  legacyHeaders?: boolean;
337
264
  skipSuccessfulRequests?: boolean;
338
265
  skipFailedRequests?: boolean;
266
+ keyGenerator?: (req: any) => string;
267
+ skip?: (req: any) => boolean;
339
268
  }
340
269
  /**
341
270
  * Creates a rate limiter middleware with configurable options.
342
271
  *
343
272
  * @param config - Rate limiting configuration
344
273
  * @returns Express rate limit middleware
274
+ * @throws Error if configuration is invalid
345
275
  */
346
276
  declare function createRateLimiter(config?: RateLimitConfig): express_rate_limit.RateLimitRequestHandler;
347
277
  /**
@@ -446,4 +376,4 @@ declare function requestLoggerMiddleware(options?: {
446
376
  */
447
377
  declare function getRequestLogger(req: Request): Logger;
448
378
 
449
- 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 };