glasswork 0.1.0 → 0.2.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.
- package/README.md +22 -43
- package/dist/config/config-service.d.ts +101 -0
- package/dist/config/config-service.d.ts.map +1 -0
- package/dist/config/config-service.js +164 -0
- package/dist/config/config-service.js.map +1 -0
- package/dist/config/helpers.d.ts +101 -0
- package/dist/config/helpers.d.ts.map +1 -0
- package/dist/config/helpers.js +122 -0
- package/dist/config/helpers.js.map +1 -0
- package/dist/config/index.d.ts +39 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +41 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/providers.d.ts +163 -0
- package/dist/config/providers.d.ts.map +1 -0
- package/dist/config/providers.js +188 -0
- package/dist/config/providers.js.map +1 -0
- package/dist/config/types.d.ts +98 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/config/types.js +7 -0
- package/dist/config/types.js.map +1 -0
- package/dist/core/bootstrap.js +9 -3
- package/dist/core/bootstrap.js.map +1 -1
- package/dist/core/types.d.ts +2 -1
- package/dist/core/types.d.ts.map +1 -1
- package/dist/http/error-response.dto.d.ts +76 -0
- package/dist/http/error-response.dto.d.ts.map +1 -0
- package/dist/http/error-response.dto.js +67 -0
- package/dist/http/error-response.dto.js.map +1 -0
- package/dist/http/errors.d.ts +39 -0
- package/dist/http/errors.d.ts.map +1 -1
- package/dist/http/errors.js +78 -0
- package/dist/http/errors.js.map +1 -1
- package/dist/http/route-helpers.d.ts +13 -6
- package/dist/http/route-helpers.d.ts.map +1 -1
- package/dist/http/route-helpers.js +29 -1
- package/dist/http/route-helpers.js.map +1 -1
- package/dist/index.d.ts +6 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -5
- package/dist/index.js.map +1 -1
- package/dist/middleware/rate-limit.d.ts.map +1 -1
- package/dist/middleware/rate-limit.js +2 -16
- package/dist/middleware/rate-limit.js.map +1 -1
- package/dist/openapi/defaults.d.ts.map +1 -1
- package/dist/openapi/defaults.js +6 -38
- package/dist/openapi/defaults.js.map +1 -1
- package/dist/openapi/openapi.d.ts +1 -1
- package/dist/openapi/openapi.d.ts.map +1 -1
- package/dist/openapi/openapi.js +21 -3
- package/dist/openapi/openapi.js.map +1 -1
- package/package.json +25 -2
- package/dist/bootstrap.d.ts +0 -55
- package/dist/bootstrap.d.ts.map +0 -1
- package/dist/bootstrap.js +0 -359
- package/dist/bootstrap.js.map +0 -1
- package/dist/environment.d.ts +0 -21
- package/dist/environment.d.ts.map +0 -1
- package/dist/environment.js +0 -29
- package/dist/environment.js.map +0 -1
- package/dist/error-handler.d.ts +0 -33
- package/dist/error-handler.d.ts.map +0 -1
- package/dist/error-handler.js +0 -53
- package/dist/error-handler.js.map +0 -1
- package/dist/errors.d.ts +0 -36
- package/dist/errors.d.ts.map +0 -1
- package/dist/errors.js +0 -65
- package/dist/errors.js.map +0 -1
- package/dist/get-client-ip.d.ts +0 -24
- package/dist/get-client-ip.d.ts.map +0 -1
- package/dist/get-client-ip.js +0 -49
- package/dist/get-client-ip.js.map +0 -1
- package/dist/logger.d.ts +0 -37
- package/dist/logger.d.ts.map +0 -1
- package/dist/logger.js +0 -52
- package/dist/logger.js.map +0 -1
- package/dist/module.d.ts +0 -21
- package/dist/module.d.ts.map +0 -1
- package/dist/module.js +0 -85
- package/dist/module.js.map +0 -1
- package/dist/omit.d.ts +0 -20
- package/dist/omit.d.ts.map +0 -1
- package/dist/omit.js +0 -28
- package/dist/omit.js.map +0 -1
- package/dist/openapi-defaults.d.ts +0 -11
- package/dist/openapi-defaults.d.ts.map +0 -1
- package/dist/openapi-defaults.js +0 -127
- package/dist/openapi-defaults.js.map +0 -1
- package/dist/openapi-hooks.d.ts +0 -14
- package/dist/openapi-hooks.d.ts.map +0 -1
- package/dist/openapi-hooks.js +0 -80
- package/dist/openapi-hooks.js.map +0 -1
- package/dist/openapi.d.ts +0 -24
- package/dist/openapi.d.ts.map +0 -1
- package/dist/openapi.js +0 -106
- package/dist/openapi.js.map +0 -1
- package/dist/pagination.d.ts +0 -48
- package/dist/pagination.d.ts.map +0 -1
- package/dist/pagination.js +0 -43
- package/dist/pagination.js.map +0 -1
- package/dist/pick.d.ts +0 -20
- package/dist/pick.d.ts.map +0 -1
- package/dist/pick.js +0 -28
- package/dist/pick.js.map +0 -1
- package/dist/rate-limit.d.ts +0 -7
- package/dist/rate-limit.d.ts.map +0 -1
- package/dist/rate-limit.js +0 -180
- package/dist/rate-limit.js.map +0 -1
- package/dist/route-helpers.d.ts +0 -172
- package/dist/route-helpers.d.ts.map +0 -1
- package/dist/route-helpers.js +0 -249
- package/dist/route-helpers.js.map +0 -1
- package/dist/serialize-dates.d.ts +0 -27
- package/dist/serialize-dates.d.ts.map +0 -1
- package/dist/serialize-dates.js +0 -39
- package/dist/serialize-dates.js.map +0 -1
- package/dist/testing.d.ts +0 -87
- package/dist/testing.d.ts.map +0 -1
- package/dist/testing.js +0 -94
- package/dist/testing.js.map +0 -1
- package/dist/types.d.ts +0 -273
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -2
- package/dist/types.js.map +0 -1
- package/dist/utils.d.ts +0 -9
- package/dist/utils.d.ts.map +0 -1
- package/dist/utils.js +0 -31
- package/dist/utils.js.map +0 -1
package/dist/environment.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Environment detection utilities for serverless and local development.
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Check if running in AWS Lambda environment
|
|
6
|
-
*/
|
|
7
|
-
export declare function isLambda(): boolean;
|
|
8
|
-
/**
|
|
9
|
-
* Check if running in production environment
|
|
10
|
-
* (either NODE_ENV=production or in Lambda)
|
|
11
|
-
*/
|
|
12
|
-
export declare function isProduction(): boolean;
|
|
13
|
-
/**
|
|
14
|
-
* Check if running in test environment
|
|
15
|
-
*/
|
|
16
|
-
export declare function isTest(): boolean;
|
|
17
|
-
/**
|
|
18
|
-
* Check if running in development environment
|
|
19
|
-
*/
|
|
20
|
-
export declare function isDevelopment(): boolean;
|
|
21
|
-
//# sourceMappingURL=environment.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"environment.d.ts","sourceRoot":"","sources":["../src/environment.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,wBAAgB,QAAQ,IAAI,OAAO,CAElC;AAED;;;GAGG;AACH,wBAAgB,YAAY,IAAI,OAAO,CAEtC;AAED;;GAEG;AACH,wBAAgB,MAAM,IAAI,OAAO,CAEhC;AAED;;GAEG;AACH,wBAAgB,aAAa,IAAI,OAAO,CAEvC"}
|
package/dist/environment.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Environment detection utilities for serverless and local development.
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Check if running in AWS Lambda environment
|
|
6
|
-
*/
|
|
7
|
-
export function isLambda() {
|
|
8
|
-
return !!(process.env.AWS_LAMBDA_FUNCTION_NAME || process.env.LAMBDA_TASK_ROOT);
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Check if running in production environment
|
|
12
|
-
* (either NODE_ENV=production or in Lambda)
|
|
13
|
-
*/
|
|
14
|
-
export function isProduction() {
|
|
15
|
-
return process.env.NODE_ENV === 'production' || isLambda();
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Check if running in test environment
|
|
19
|
-
*/
|
|
20
|
-
export function isTest() {
|
|
21
|
-
return process.env.NODE_ENV === 'test';
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Check if running in development environment
|
|
25
|
-
*/
|
|
26
|
-
export function isDevelopment() {
|
|
27
|
-
return !isProduction() && !isTest();
|
|
28
|
-
}
|
|
29
|
-
//# sourceMappingURL=environment.js.map
|
package/dist/environment.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"environment.js","sourceRoot":"","sources":["../src/environment.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,UAAU,QAAQ;IACtB,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,wBAAwB,IAAI,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;AAClF,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY;IAC1B,OAAO,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,IAAI,QAAQ,EAAE,CAAC;AAC7D,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,MAAM;IACpB,OAAO,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,MAAM,CAAC;AACzC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa;IAC3B,OAAO,CAAC,YAAY,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC;AACtC,CAAC"}
|
package/dist/error-handler.d.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import type { Context, ErrorHandler } from 'hono';
|
|
2
|
-
import type { ContentfulStatusCode } from 'hono/utils/http-status';
|
|
3
|
-
interface FormattedError {
|
|
4
|
-
message: string;
|
|
5
|
-
statusCode: ContentfulStatusCode;
|
|
6
|
-
}
|
|
7
|
-
interface ErrorHandlerOptions {
|
|
8
|
-
/**
|
|
9
|
-
* Whether to log errors to console
|
|
10
|
-
* @default true in development, false in test
|
|
11
|
-
*/
|
|
12
|
-
logErrors?: boolean;
|
|
13
|
-
/**
|
|
14
|
-
* Custom error response handler
|
|
15
|
-
*/
|
|
16
|
-
responseHandler?: (error: FormattedError, context: Context) => Response | Promise<Response>;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Create an error handler middleware for Hono
|
|
20
|
-
*
|
|
21
|
-
* Handles:
|
|
22
|
-
* - DomainException (custom business logic exceptions)
|
|
23
|
-
* - HTTPException (Hono's built-in HTTP exceptions)
|
|
24
|
-
* - Validation errors (returns 422)
|
|
25
|
-
* - Generic errors (returns 500)
|
|
26
|
-
*/
|
|
27
|
-
export declare function createErrorHandler(options?: ErrorHandlerOptions): ErrorHandler;
|
|
28
|
-
/**
|
|
29
|
-
* Default error handler instance
|
|
30
|
-
*/
|
|
31
|
-
export declare const defaultErrorHandler: ErrorHandler;
|
|
32
|
-
export {};
|
|
33
|
-
//# sourceMappingURL=error-handler.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"error-handler.d.ts","sourceRoot":"","sources":["../src/error-handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAElD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAGnE,UAAU,cAAc;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,oBAAoB,CAAC;CAClC;AAED,UAAU,mBAAmB;IAC3B;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;OAEG;IACH,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,OAAO,KAAK,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;CAC7F;AAcD;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,GAAE,mBAAwB,GAAG,YAAY,CA+BlF;AAED;;GAEG;AACH,eAAO,MAAM,mBAAmB,cAAuB,CAAC"}
|
package/dist/error-handler.js
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { HTTPException } from 'hono/http-exception';
|
|
2
|
-
import { DomainException, getStatusCodeFromErrorCode } from './errors.js';
|
|
3
|
-
/**
|
|
4
|
-
* Default response handler - returns JSON error
|
|
5
|
-
*/
|
|
6
|
-
function defaultResponseHandler(error, context) {
|
|
7
|
-
return context.json({
|
|
8
|
-
error: error.message,
|
|
9
|
-
}, error.statusCode);
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Create an error handler middleware for Hono
|
|
13
|
-
*
|
|
14
|
-
* Handles:
|
|
15
|
-
* - DomainException (custom business logic exceptions)
|
|
16
|
-
* - HTTPException (Hono's built-in HTTP exceptions)
|
|
17
|
-
* - Validation errors (returns 422)
|
|
18
|
-
* - Generic errors (returns 500)
|
|
19
|
-
*/
|
|
20
|
-
export function createErrorHandler(options = {}) {
|
|
21
|
-
const { logErrors = process.env.NODE_ENV !== 'test', responseHandler = defaultResponseHandler } = options;
|
|
22
|
-
return (err, context) => {
|
|
23
|
-
let error;
|
|
24
|
-
if (err instanceof DomainException) {
|
|
25
|
-
const statusCode = getStatusCodeFromErrorCode(err.code);
|
|
26
|
-
error = { message: err.message, statusCode: statusCode };
|
|
27
|
-
if (logErrors && statusCode === 500) {
|
|
28
|
-
console.error('[Glasswork] DomainException with unknown code:', err);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
else if (err instanceof HTTPException) {
|
|
32
|
-
error = {
|
|
33
|
-
message: err.message,
|
|
34
|
-
statusCode: err.status,
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
if (logErrors) {
|
|
39
|
-
console.error('[Glasswork] Unhandled error:', err);
|
|
40
|
-
}
|
|
41
|
-
error = {
|
|
42
|
-
message: 'Internal server error',
|
|
43
|
-
statusCode: 500,
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
return responseHandler(error, context);
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Default error handler instance
|
|
51
|
-
*/
|
|
52
|
-
export const defaultErrorHandler = createErrorHandler();
|
|
53
|
-
//# sourceMappingURL=error-handler.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"error-handler.js","sourceRoot":"","sources":["../src/error-handler.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EAAE,eAAe,E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AAO,CAAC,CAAC;IACzC,CAAC,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,kBAAkB,EAAE,CAAC"}
|
package/dist/errors.d.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Base domain exception class for business logic errors
|
|
3
|
-
*/
|
|
4
|
-
export declare class DomainException extends Error {
|
|
5
|
-
readonly code: string;
|
|
6
|
-
constructor(message: string, code: string);
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Standard HTTP exception classes
|
|
10
|
-
*/
|
|
11
|
-
export declare class ValidationException extends DomainException {
|
|
12
|
-
constructor(message?: string);
|
|
13
|
-
}
|
|
14
|
-
export declare class UnauthorizedException extends DomainException {
|
|
15
|
-
constructor(message?: string);
|
|
16
|
-
}
|
|
17
|
-
export declare class NotFoundException extends DomainException {
|
|
18
|
-
constructor(message?: string);
|
|
19
|
-
}
|
|
20
|
-
export declare class ConflictException extends DomainException {
|
|
21
|
-
constructor(message?: string);
|
|
22
|
-
}
|
|
23
|
-
export declare class ForbiddenException extends DomainException {
|
|
24
|
-
constructor(message?: string);
|
|
25
|
-
}
|
|
26
|
-
export declare class BadRequestException extends DomainException {
|
|
27
|
-
constructor(message?: string);
|
|
28
|
-
}
|
|
29
|
-
export declare class TooManyRequestsException extends DomainException {
|
|
30
|
-
constructor(message?: string);
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Map error codes to HTTP status codes
|
|
34
|
-
*/
|
|
35
|
-
export declare function getStatusCodeFromErrorCode(code: string): number;
|
|
36
|
-
//# sourceMappingURL=errors.d.ts.map
|
package/dist/errors.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,eAAgB,SAAQ,KAAK;aAGtB,IAAI,EAAE,MAAM;gBAD5B,OAAO,EAAE,MAAM,EACC,IAAI,EAAE,MAAM;CAK/B;AAED;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,eAAe;gBAC1C,OAAO,SAAqB;CAGzC;AAED,qBAAa,qBAAsB,SAAQ,eAAe;gBAC5C,OAAO,SAAiB;CAGrC;AAED,qBAAa,iBAAkB,SAAQ,eAAe;gBACxC,OAAO,SAAc;CAGlC;AAED,qBAAa,iBAAkB,SAAQ,eAAe;gBACxC,OAAO,SAAa;CAGjC;AAED,qBAAa,kBAAmB,SAAQ,eAAe;gBACzC,OAAO,SAAc;CAGlC;AAED,qBAAa,mBAAoB,SAAQ,eAAe;gBAC1C,OAAO,SAAgB;CAGpC;AAED,qBAAa,wBAAyB,SAAQ,eAAe;gBAC/C,OAAO,SAAsB;CAG1C;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAY/D"}
|
package/dist/errors.js
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Base domain exception class for business logic errors
|
|
3
|
-
*/
|
|
4
|
-
export class DomainException extends Error {
|
|
5
|
-
code;
|
|
6
|
-
constructor(message, code) {
|
|
7
|
-
super(message);
|
|
8
|
-
this.code = code;
|
|
9
|
-
this.name = this.constructor.name;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Standard HTTP exception classes
|
|
14
|
-
*/
|
|
15
|
-
export class ValidationException extends DomainException {
|
|
16
|
-
constructor(message = 'Validation error') {
|
|
17
|
-
super(message, 'VALIDATION_ERROR');
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
export class UnauthorizedException extends DomainException {
|
|
21
|
-
constructor(message = 'Unauthorized') {
|
|
22
|
-
super(message, 'UNAUTHORIZED');
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
export class NotFoundException extends DomainException {
|
|
26
|
-
constructor(message = 'Not found') {
|
|
27
|
-
super(message, 'NOT_FOUND');
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
export class ConflictException extends DomainException {
|
|
31
|
-
constructor(message = 'Conflict') {
|
|
32
|
-
super(message, 'CONFLICT');
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
export class ForbiddenException extends DomainException {
|
|
36
|
-
constructor(message = 'Forbidden') {
|
|
37
|
-
super(message, 'FORBIDDEN');
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
export class BadRequestException extends DomainException {
|
|
41
|
-
constructor(message = 'Bad request') {
|
|
42
|
-
super(message, 'BAD_REQUEST');
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
export class TooManyRequestsException extends DomainException {
|
|
46
|
-
constructor(message = 'Too many requests') {
|
|
47
|
-
super(message, 'TOO_MANY_REQUESTS');
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Map error codes to HTTP status codes
|
|
52
|
-
*/
|
|
53
|
-
export function getStatusCodeFromErrorCode(code) {
|
|
54
|
-
const codeMap = {
|
|
55
|
-
BAD_REQUEST: 400,
|
|
56
|
-
UNAUTHORIZED: 401,
|
|
57
|
-
FORBIDDEN: 403,
|
|
58
|
-
NOT_FOUND: 404,
|
|
59
|
-
CONFLICT: 409,
|
|
60
|
-
VALIDATION_ERROR: 422,
|
|
61
|
-
TOO_MANY_REQUESTS: 429,
|
|
62
|
-
};
|
|
63
|
-
return codeMap[code] || 500;
|
|
64
|
-
}
|
|
65
|
-
//# sourceMappingURL=errors.js.map
|
package/dist/errors.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,OAAO,eAAgB,SAAQ,KAAK;IAGtB;IAFlB,YACE,OAAe,EACC,IAAY;QAE5B,KAAK,CAAC,OAAO,CAAC,CAAC;QAFC,SAAI,GAAJ,IAAI,CAAQ;QAG5B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AAG;QACb,gBAAgB,EAAE,GAAG;QACrB,iBAAiB,EAAE,GAAG;KACvB,CAAC;IAEF,OAAO,OAAO,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC;AAC9B,CAAC"}
|
package/dist/get-client-ip.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { Context } from 'hono';
|
|
2
|
-
/**
|
|
3
|
-
* Extract the client IP address from Hono context.
|
|
4
|
-
*
|
|
5
|
-
* Checks headers in order:
|
|
6
|
-
* 1. x-forwarded-for (proxy/load balancer)
|
|
7
|
-
* 2. x-real-ip (nginx)
|
|
8
|
-
* 3. Direct connection info (if available)
|
|
9
|
-
*
|
|
10
|
-
* @param c - Hono context
|
|
11
|
-
* @returns Client IP address or 'unknown' if not determinable
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```typescript
|
|
15
|
-
* router.post('/login', route({
|
|
16
|
-
* handler: async ({ ip }) => {
|
|
17
|
-
* // ip is automatically populated
|
|
18
|
-
* await authService.logLoginAttempt(email, ip);
|
|
19
|
-
* }
|
|
20
|
-
* }));
|
|
21
|
-
* ```
|
|
22
|
-
*/
|
|
23
|
-
export declare function getClientIp(c: Context): string;
|
|
24
|
-
//# sourceMappingURL=get-client-ip.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-client-ip.d.ts","sourceRoot":"","sources":["../src/get-client-ip.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAEpC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,OAAO,GAAG,MAAM,CA0B9C"}
|
package/dist/get-client-ip.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Extract the client IP address from Hono context.
|
|
3
|
-
*
|
|
4
|
-
* Checks headers in order:
|
|
5
|
-
* 1. x-forwarded-for (proxy/load balancer)
|
|
6
|
-
* 2. x-real-ip (nginx)
|
|
7
|
-
* 3. Direct connection info (if available)
|
|
8
|
-
*
|
|
9
|
-
* @param c - Hono context
|
|
10
|
-
* @returns Client IP address or 'unknown' if not determinable
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```typescript
|
|
14
|
-
* router.post('/login', route({
|
|
15
|
-
* handler: async ({ ip }) => {
|
|
16
|
-
* // ip is automatically populated
|
|
17
|
-
* await authService.logLoginAttempt(email, ip);
|
|
18
|
-
* }
|
|
19
|
-
* }));
|
|
20
|
-
* ```
|
|
21
|
-
*/
|
|
22
|
-
export function getClientIp(c) {
|
|
23
|
-
// Check x-forwarded-for header (proxy/load balancer)
|
|
24
|
-
const xForwardedFor = c.req.header('x-forwarded-for');
|
|
25
|
-
if (xForwardedFor) {
|
|
26
|
-
const ip = xForwardedFor.split(',')[0].trim();
|
|
27
|
-
if (ip)
|
|
28
|
-
return ip;
|
|
29
|
-
}
|
|
30
|
-
// Check x-real-ip header (nginx)
|
|
31
|
-
const xRealIp = c.req.header('x-real-ip');
|
|
32
|
-
if (xRealIp)
|
|
33
|
-
return xRealIp;
|
|
34
|
-
// Try to get connection info (Node.js server)
|
|
35
|
-
try {
|
|
36
|
-
// Dynamic import to avoid bundling @hono/node-server in Lambda
|
|
37
|
-
// This will throw in non-Node environments
|
|
38
|
-
const { getConnInfo } = require('@hono/node-server/conninfo');
|
|
39
|
-
const info = getConnInfo(c);
|
|
40
|
-
if (info?.remote?.address) {
|
|
41
|
-
return info.remote.address;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
catch {
|
|
45
|
-
// Not in Node.js environment or module not available
|
|
46
|
-
}
|
|
47
|
-
return 'unknown';
|
|
48
|
-
}
|
|
49
|
-
//# sourceMappingURL=get-client-ip.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-client-ip.js","sourceRoot":"","sources":["../src/get-client-ip.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,WAAW,CAAC,CAAU;IACpC,qDAAqD;IACrD,MAAM,aAAa,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC;IACtD,IAAI,aAAa,EAAE,CAAC;QAClB,MAAM,EAAE,GAAG,aAAa,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QAC9C,IAAI,EAAE;YAAE,OAAO,EAAE,CAAC;IACpB,CAAC;IAED,iCAAiC;IACjC,MAAM,OAAO,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IAC1C,IAAI,OAAO;QAAE,OAAO,OAAO,CAAC;IAE5B,8CAA8C;IAC9C,IAAI,CAAC;QACH,+DAA+D;QAC/D,2CAA2C;QAC3C,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAAC;QAC9D,MAAM,IAAI,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;QAC5B,IAAI,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;YAC1B,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC;QAC7B,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,qDAAqD;IACvD,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
package/dist/logger.d.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Logger interface for framework and application logging
|
|
3
|
-
*/
|
|
4
|
-
export interface Logger {
|
|
5
|
-
debug(message: string, ...meta: unknown[]): void;
|
|
6
|
-
info(message: string, ...meta: unknown[]): void;
|
|
7
|
-
warn(message: string, ...meta: unknown[]): void;
|
|
8
|
-
error(message: string, ...meta: unknown[]): void;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Default console logger (used by framework internally)
|
|
12
|
-
*/
|
|
13
|
-
export declare const defaultLogger: Logger;
|
|
14
|
-
/**
|
|
15
|
-
* Create a logger with a prefix for namespacing
|
|
16
|
-
*
|
|
17
|
-
* @param prefix - Prefix to add to all log messages
|
|
18
|
-
* @param enabled - Whether logging is enabled (default: true)
|
|
19
|
-
* @returns Logger instance
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* ```typescript
|
|
23
|
-
* const logger = createLogger('MyService', debug);
|
|
24
|
-
* logger.info('Starting service'); // [MyService] Starting service
|
|
25
|
-
* ```
|
|
26
|
-
*/
|
|
27
|
-
export declare function createLogger(prefix: string, enabled?: boolean): Logger;
|
|
28
|
-
/**
|
|
29
|
-
* Create a plain logger middleware for Lambda (strips ANSI color codes).
|
|
30
|
-
*
|
|
31
|
-
* CloudWatch Logs doesn't render ANSI colors well, so this middleware
|
|
32
|
-
* strips them for cleaner logs in production.
|
|
33
|
-
*
|
|
34
|
-
* @returns Hono logger middleware with ANSI codes stripped
|
|
35
|
-
*/
|
|
36
|
-
export declare function createPlainLogger(): import("hono").MiddlewareHandler;
|
|
37
|
-
//# sourceMappingURL=logger.d.ts.map
|
package/dist/logger.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,WAAW,MAAM;IACrB,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IACjD,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAChD,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAChD,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;CAClD;AAED;;GAEG;AACH,eAAO,MAAM,aAAa,EAAE,MAK3B,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,UAAO,GAAG,MAAM,CAYnE;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,qCAQhC"}
|
package/dist/logger.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { logger as honoLogger } from 'hono/logger';
|
|
2
|
-
/**
|
|
3
|
-
* Default console logger (used by framework internally)
|
|
4
|
-
*/
|
|
5
|
-
export const defaultLogger = {
|
|
6
|
-
debug: console.debug.bind(console),
|
|
7
|
-
info: console.log.bind(console),
|
|
8
|
-
warn: console.warn.bind(console),
|
|
9
|
-
error: console.error.bind(console),
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* Create a logger with a prefix for namespacing
|
|
13
|
-
*
|
|
14
|
-
* @param prefix - Prefix to add to all log messages
|
|
15
|
-
* @param enabled - Whether logging is enabled (default: true)
|
|
16
|
-
* @returns Logger instance
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* ```typescript
|
|
20
|
-
* const logger = createLogger('MyService', debug);
|
|
21
|
-
* logger.info('Starting service'); // [MyService] Starting service
|
|
22
|
-
* ```
|
|
23
|
-
*/
|
|
24
|
-
export function createLogger(prefix, enabled = true) {
|
|
25
|
-
if (!enabled) {
|
|
26
|
-
const noop = () => { };
|
|
27
|
-
return { debug: noop, info: noop, warn: noop, error: noop };
|
|
28
|
-
}
|
|
29
|
-
return {
|
|
30
|
-
debug: (msg, ...meta) => console.debug(`[${prefix}] ${msg}`, ...meta),
|
|
31
|
-
info: (msg, ...meta) => console.log(`[${prefix}] ${msg}`, ...meta),
|
|
32
|
-
warn: (msg, ...meta) => console.warn(`[${prefix}] ${msg}`, ...meta),
|
|
33
|
-
error: (msg, ...meta) => console.error(`[${prefix}] ${msg}`, ...meta),
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Create a plain logger middleware for Lambda (strips ANSI color codes).
|
|
38
|
-
*
|
|
39
|
-
* CloudWatch Logs doesn't render ANSI colors well, so this middleware
|
|
40
|
-
* strips them for cleaner logs in production.
|
|
41
|
-
*
|
|
42
|
-
* @returns Hono logger middleware with ANSI codes stripped
|
|
43
|
-
*/
|
|
44
|
-
export function createPlainLogger() {
|
|
45
|
-
// biome-ignore lint/suspicious/noControlCharactersInRegex: we want to strip ANSI color codes
|
|
46
|
-
const stripAnsi = (input) => input.replace(/\u001B\[[0-9;]*m/g, '');
|
|
47
|
-
return honoLogger((str, ...rest) => {
|
|
48
|
-
const message = [str, ...rest].join(' ');
|
|
49
|
-
console.log(stripAnsi(message));
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
//# sourceMappingURL=logger.js.map
|
package/dist/logger.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,aAAa,CAAC;AAYnD;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAW;IACnC,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC;IAClC,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC;IAC/B,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC;IAChC,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC;CACnC,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,YAAY,CAAC,MAAc,EAAE,OAAO,GAAG,IAAI;IACzD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC;QACtB,OAAO,EAAE,KAAK,EAAE,IAAI,E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
|
-
/**
|
|
3
|
-
* Define a module with providers, imports, and routes.
|
|
4
|
-
*
|
|
5
|
-
* This is a pure metadata function - it just returns the configuration.
|
|
6
|
-
* The actual registration happens in the bootstrap function.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```typescript
|
|
10
|
-
* export const AuthModule = defineModule({
|
|
11
|
-
* name: 'auth',
|
|
12
|
-
* basePath: 'auth',
|
|
13
|
-
* providers: [AuthService, UserService],
|
|
14
|
-
* imports: [CommonModule],
|
|
15
|
-
* exports: [AuthService],
|
|
16
|
-
* routes: AuthRoutes,
|
|
17
|
-
* });
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
|
-
export declare function defineModule(config: ModuleConfig): ModuleConfig;
|
|
21
|
-
//# sourceMappingURL=module.d.ts.map
|
package/dist/module.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAe,YAAY,EAAkB,MAAM,YAAY,CAAC;AAE5E;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,YAAY,GAAG,YAAY,CAG/D"}
|
package/dist/module.js
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Define a module with providers, imports, and routes.
|
|
3
|
-
*
|
|
4
|
-
* This is a pure metadata function - it just returns the configuration.
|
|
5
|
-
* The actual registration happens in the bootstrap function.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* ```typescript
|
|
9
|
-
* export const AuthModule = defineModule({
|
|
10
|
-
* name: 'auth',
|
|
11
|
-
* basePath: 'auth',
|
|
12
|
-
* providers: [AuthService, UserService],
|
|
13
|
-
* imports: [CommonModule],
|
|
14
|
-
* exports: [AuthService],
|
|
15
|
-
* routes: AuthRoutes,
|
|
16
|
-
* });
|
|
17
|
-
* ```
|
|
18
|
-
*/
|
|
19
|
-
export function defineModule(config) {
|
|
20
|
-
validateModuleConfig(config);
|
|
21
|
-
return config;
|
|
22
|
-
}
|
|
23
|
-
function validateModuleConfig(config) {
|
|
24
|
-
validateModuleName(config.name);
|
|
25
|
-
validateProviders(config);
|
|
26
|
-
validateExports(config);
|
|
27
|
-
}
|
|
28
|
-
function validateModuleName(name) {
|
|
29
|
-
if (!name) {
|
|
30
|
-
throw new Error('Module name is required');
|
|
31
|
-
}
|
|
32
|
-
if (name.includes('/') || name.includes(' ')) {
|
|
33
|
-
throw new Error('Module name must not contain "/" or spaces');
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
function validateProviders(config) {
|
|
37
|
-
if (!config.providers) {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
for (const provider of config.providers) {
|
|
41
|
-
if (typeof provider !== 'function' && typeof provider !== 'object') {
|
|
42
|
-
throw new Error(`Invalid provider in module "${config.name}"`);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
function validateExports(config) {
|
|
47
|
-
if (!config.exports || !config.providers) {
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
const providerNames = collectProviderNames(config.providers);
|
|
51
|
-
for (const exp of config.exports) {
|
|
52
|
-
const exportName = getProviderName(exp);
|
|
53
|
-
if (!providerNames.has(exportName)) {
|
|
54
|
-
throw new Error(`Module "${config.name}" exports "${exportName}" but it's not in providers`);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
function collectProviderNames(providers) {
|
|
59
|
-
const names = new Set();
|
|
60
|
-
for (const provider of providers) {
|
|
61
|
-
names.add(getProviderName(provider));
|
|
62
|
-
}
|
|
63
|
-
return names;
|
|
64
|
-
}
|
|
65
|
-
function getProviderName(provider) {
|
|
66
|
-
if (typeof provider === 'string') {
|
|
67
|
-
return provider;
|
|
68
|
-
}
|
|
69
|
-
if (typeof provider === 'function') {
|
|
70
|
-
return camelCase(provider.name);
|
|
71
|
-
}
|
|
72
|
-
if ('provide' in provider) {
|
|
73
|
-
return typeof provider.provide === 'string'
|
|
74
|
-
? provider.provide
|
|
75
|
-
: camelCase(provider.provide.name);
|
|
76
|
-
}
|
|
77
|
-
return '';
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Convert PascalCase to camelCase
|
|
81
|
-
*/
|
|
82
|
-
function camelCase(str) {
|
|
83
|
-
return str.charAt(0).toLowerCase() + str.slice(1);
|
|
84
|
-
}
|
|
85
|
-
//# sourceMappingURL=module.js.map
|
package/dist/module.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"module.js","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,YAAY,CAAC,MAAoB;IAC/C,oBAAoB,CAAC,MAAM,CAAC,CAAC;IAC7B,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,oBAAoB,CAAC,MAAoB;IAChD,kBAAkB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAChC,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAC1B,eAAe,CAAC,MAAM,CAAC,CAAC;AAC1B,CAAC;AAED,SAAS,kBAAkB,CAAC,IAAY;IACtC,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;IAED,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QAC7C,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;IAChE,CAAC;AACH,CAAC;AAED,SAAS,iBAAiB,CAAC,MAAoB;IAC7C,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC;QACtB,OAAO;IACT,CAAC;IAED,KAAK,MAAM,QAAQ,IAAI,MAAM,CAAC,SAAS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,OAAO,OAAO,QAAQ,CAAC,OAAO,KAAK,QAAQ;YACzC,CAAC,CAAC,QAAQ,CAAC,OAAO;YAClB,CAAC,CAAC,SAAS,CAAE,QAAQ,CAAC,OAAuB,CAAC,IAAI,CAAC,CAAC;IACxD,CAAC;IAED,OAAO,EAAE,CAAC;AACZ,CAAC;AAED;;GAEG;AACH,SAAS,SAAS,CAAC,GAAW;IAC5B,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACpD,CAAC"}
|
package/dist/omit.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Creates a new object by omitting specified keys from the source object.
|
|
3
|
-
*
|
|
4
|
-
* This implementation preserves the object's prototype, making it suitable
|
|
5
|
-
* for use with class instances and objects with custom prototypes.
|
|
6
|
-
*
|
|
7
|
-
* @template T - The type of the source object
|
|
8
|
-
* @template K - The type of keys to omit (must be keys of T)
|
|
9
|
-
* @param object - The source object to omit keys from
|
|
10
|
-
* @param paths - Array of keys to omit from the object
|
|
11
|
-
* @returns A new object with the specified keys omitted
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```typescript
|
|
15
|
-
* const user = { id: 1, name: 'John', email: 'john@example.com', password: 'secret' };
|
|
16
|
-
* const publicUser = omit(user, ['password']); // { id: 1, name: 'John', email: 'john@example.com' }
|
|
17
|
-
* ```
|
|
18
|
-
*/
|
|
19
|
-
export declare function omit<T extends object, K extends keyof T>(object: T, paths: K[]): Omit<T, K>;
|
|
20
|
-
//# sourceMappingURL=omit.d.ts.map
|
package/dist/omit.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"omit.d.ts","sourceRoot":"","sources":["../src/omit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAU3F"}
|
package/dist/omit.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Creates a new object by omitting specified keys from the source object.
|
|
3
|
-
*
|
|
4
|
-
* This implementation preserves the object's prototype, making it suitable
|
|
5
|
-
* for use with class instances and objects with custom prototypes.
|
|
6
|
-
*
|
|
7
|
-
* @template T - The type of the source object
|
|
8
|
-
* @template K - The type of keys to omit (must be keys of T)
|
|
9
|
-
* @param object - The source object to omit keys from
|
|
10
|
-
* @param paths - Array of keys to omit from the object
|
|
11
|
-
* @returns A new object with the specified keys omitted
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```typescript
|
|
15
|
-
* const user = { id: 1, name: 'John', email: 'john@example.com', password: 'secret' };
|
|
16
|
-
* const publicUser = omit(user, ['password']); // { id: 1, name: 'John', email: 'john@example.com' }
|
|
17
|
-
* ```
|
|
18
|
-
*/
|
|
19
|
-
export function omit(object, paths) {
|
|
20
|
-
const result = Object.create(Object.getPrototypeOf(object));
|
|
21
|
-
for (const key in object) {
|
|
22
|
-
if (Object.hasOwn(object, key) && !paths.includes(key)) {
|
|
23
|
-
result[key] = object[key];
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
return result;
|
|
27
|
-
}
|
|
28
|
-
//# sourceMappingURL=omit.js.map
|
package/dist/omit.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"omit.js","sourceRoot":"","sources":["../src/omit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,IAAI,CAAsC,MAAS,EAAE,KAAU;IAC7E,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC;IAE5D,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;QACzB,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAmB,CAAC,EAAE,CAAC;YACvE,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { OpenAPIV3 } from 'openapi-types';
|
|
2
|
-
/**
|
|
3
|
-
* Default OpenAPI components provided by Glasswork.
|
|
4
|
-
* These include headers for features implemented by the framework:
|
|
5
|
-
* - Rate limiting headers
|
|
6
|
-
* - Pagination headers
|
|
7
|
-
* - CORS headers
|
|
8
|
-
* - Error response schemas
|
|
9
|
-
*/
|
|
10
|
-
export declare const defaultOpenAPIComponents: OpenAPIV3.ComponentsObject;
|
|
11
|
-
//# sourceMappingURL=openapi-defaults.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"openapi-defaults.d.ts","sourceRoot":"","sources":["../src/openapi-defaults.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE/C;;;;;;;GAOG;AACH,eAAO,MAAM,wBAAwB,EAAE,SAAS,CAAC,gBAuHhD,CAAC"}
|