speexjs 0.3.0 → 0.5.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.
@@ -1,9 +1,10 @@
1
1
  import { A as AuthUser } from '../../session-guard-CZeN87L9.js';
2
- import { M as Middleware } from '../../index-CMkhSDh7.js';
2
+ import { M as Middleware } from '../../index-C4xilc_E.js';
3
3
  import '../../response-Ca8KWK5_.js';
4
4
  import 'node:http';
5
5
  import 'node:stream';
6
6
  import '../container/index.js';
7
+ import '../../types-aW38f63o.js';
7
8
 
8
9
  declare class AuthorizationError extends Error {
9
10
  readonly ability: string;
@@ -1,12 +1,13 @@
1
1
  import { Container } from './container/index.js';
2
2
  import { Server } from 'node:http';
3
3
  import { S as SuperRequest, a as SuperResponse } from '../response-Ca8KWK5_.js';
4
- import { a as Router, M as Middleware, b as RouteHandler, C as ControllerClass, S as StaticOptions, R as RouteContext } from '../index-CMkhSDh7.js';
4
+ import { a as Router, M as Middleware, b as RouteHandler, C as ControllerClass, S as StaticOptions, R as RouteContext } from '../index-C4xilc_E.js';
5
5
  export { Cache, CacheConfig, cacheResponse } from './cache/index.js';
6
6
  export { ColumnCompileOptions, ColumnDefinition, ConnectionConfig, DatabaseConnection, DatabaseDriver, Dialect, Driver, ForeignKeyDefinition, MigrationDefinition, MigrationStatusRow, Migrator, Model, MysqlDialect, PaginatedResult, Pagination, PaginationUrl, PostgresqlDialect, QueryBuilder, QueryResult, SchemaBuilder, Seeder, SeederClass, SqliteDialect, TableBlueprint, createDialect, createDriver } from './database/index.js';
7
7
  export { Event, EventConfig, createEvent, event } from './events/index.js';
8
8
  export { LocalDisk, Storage, StorageConfig, createStorage, storage } from './storage/index.js';
9
9
  import 'node:stream';
10
+ import '../types-aW38f63o.js';
10
11
  import 'node:fs';
11
12
 
12
13
  interface ServerInstance {
@@ -34,6 +35,51 @@ declare function url(): URLBuilder;
34
35
  declare function responseMacros(response: SuperResponse): void;
35
36
  declare function registerMacro(name: string, fn: (this: SuperResponse, ...args: any[]) => SuperResponse): void;
36
37
 
38
+ declare class HttpException extends Error {
39
+ readonly status: number;
40
+ readonly error: string;
41
+ constructor(message: string, status?: number, error?: string);
42
+ toJSON(): Record<string, unknown>;
43
+ }
44
+ declare class BadRequestException extends HttpException {
45
+ constructor(message?: string);
46
+ }
47
+ declare class UnauthorizedException extends HttpException {
48
+ constructor(message?: string);
49
+ }
50
+ declare class ForbiddenException extends HttpException {
51
+ constructor(message?: string);
52
+ }
53
+ declare class NotFoundException extends HttpException {
54
+ constructor(message?: string);
55
+ }
56
+ declare class MethodNotAllowedException extends HttpException {
57
+ constructor(message?: string);
58
+ }
59
+ declare class ConflictException extends HttpException {
60
+ constructor(message?: string);
61
+ }
62
+ declare class UnprocessableEntityException extends HttpException {
63
+ constructor(message?: string);
64
+ }
65
+ declare class TooManyRequestsException extends HttpException {
66
+ constructor(message?: string);
67
+ }
68
+ declare class InternalServerErrorException extends HttpException {
69
+ constructor(message?: string);
70
+ }
71
+ declare class ServiceUnavailableException extends HttpException {
72
+ constructor(message?: string);
73
+ }
74
+ declare class ValidationException extends HttpException {
75
+ readonly errors: Record<string, string[]>;
76
+ constructor(errors: Record<string, string[]>, message?: string);
77
+ toJSON(): Record<string, unknown>;
78
+ }
79
+ type ExceptionHandler = (err: HttpException) => HttpException | Promise<HttpException>;
80
+ declare function registerExceptionHandler(exceptionType: new (...args: never[]) => HttpException, handler: ExceptionHandler): void;
81
+ declare function normalizeError(_err: unknown): HttpException;
82
+
37
83
  interface ViewEngine {
38
84
  render(template: string, data: Record<string, unknown>): string | Promise<string>;
39
85
  }
@@ -49,6 +95,10 @@ declare class SuperApp {
49
95
  private globalPipeline;
50
96
  private started;
51
97
  private serverPromise;
98
+ private onErrorHandler;
99
+ private onNotFoundHandler;
100
+ private shutdownHandlers;
101
+ private shuttingDown;
52
102
  constructor(options?: AppOptions);
53
103
  use(middleware: Middleware): this;
54
104
  get(path: string, handler: RouteHandler): this;
@@ -67,9 +117,12 @@ declare class SuperApp {
67
117
  setEngine(engine: ServerEngine): this;
68
118
  static(path: string, options?: StaticOptions): this;
69
119
  view(_engine: ViewEngine): this;
120
+ onError(handler: (err: Error, ctx: RouteContext) => void | Promise<void>): this;
121
+ notFound(handler: (ctx: RouteContext) => void | Promise<void>): this;
122
+ onShutdown(handler: () => void | Promise<void>): this;
70
123
  getServer(): ServerInstance | undefined;
71
124
  start(port?: number, host?: string): Promise<void>;
72
- listen(port?: number, callback?: () => void): void;
125
+ listen(port?: number, callback?: () => void): this;
73
126
  close(): Promise<void>;
74
127
  ready(): Promise<void>;
75
128
  private handleRequest;
@@ -77,4 +130,4 @@ declare class SuperApp {
77
130
  declare function speexjs(options?: AppOptions): SuperApp;
78
131
  declare function createControllerInstance(controller: ControllerClass, ctx: RouteContext): object;
79
132
 
80
- export { type AppOptions, SuperApp, URLBuilder, type ViewEngine, createControllerInstance, registerMacro, responseMacros, speexjs, url };
133
+ export { type AppOptions, BadRequestException, ConflictException, ForbiddenException, HttpException, InternalServerErrorException, MethodNotAllowedException, NotFoundException, ServiceUnavailableException, SuperApp, TooManyRequestsException, URLBuilder, UnauthorizedException, UnprocessableEntityException, ValidationException, type ViewEngine, createControllerInstance, normalizeError, registerExceptionHandler, registerMacro, responseMacros, speexjs, url };