@polygonlabs/servercore 1.0.0-dev.5 → 1.0.0-dev.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.
- package/dist/api/index.d.ts +1 -0
- package/dist/api/response_handler.d.ts +1 -4
- package/dist/api/response_handler.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +1 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/response_context.d.ts +6 -0
- package/dist/types/response_context.js +1 -0
- package/dist/types/response_context.js.map +1 -0
- package/package.json +1 -1
package/dist/api/index.d.ts
CHANGED
@@ -1,12 +1,9 @@
|
|
1
1
|
import { ApiError } from '../errors/api_errors.js';
|
2
2
|
import { DatabaseError } from '../errors/database_errors.js';
|
3
3
|
import { ExternalDependencyError } from '../errors/external_dependency_error.js';
|
4
|
+
import { ResponseContext } from '../types/response_context.js';
|
4
5
|
import '../errors/base_error.js';
|
5
6
|
|
6
|
-
type ResponseContext = {
|
7
|
-
status: (statusCode: number) => ResponseContext;
|
8
|
-
json: (body: any) => any;
|
9
|
-
};
|
10
7
|
declare const handleResponse: (c: ResponseContext, data: any) => any;
|
11
8
|
declare const handleError: (c: ResponseContext, error: ApiError | ExternalDependencyError | DatabaseError) => any;
|
12
9
|
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/api/response_handler.ts"],"sourcesContent":["import { ApiError, DatabaseError, ExternalDependencyError } from \"../errors\"; // Define your error types\nimport { httpResposneCodes, errorCodes } from \"../constants\"; // Define your success codes\
|
1
|
+
{"version":3,"sources":["../../src/api/response_handler.ts"],"sourcesContent":["import { ApiError, DatabaseError, ExternalDependencyError } from \"../errors\"; // Define your error types\nimport { httpResposneCodes, errorCodes } from \"../constants\"; // Define your success codes\nimport type { ResponseContext } from \"../types\";\n\nexport const handleResponse = (c: ResponseContext, data: any) => {\n // This method returns a success response with the status and data.\n return c\n .status(httpResposneCodes.OK_RESPONSE) // Use success code from httpResposneCodes\n .json({\n status: \"success\",\n data: data,\n });\n};\n\nexport const handleError = (\n c: ResponseContext,\n error: ApiError | ExternalDependencyError | DatabaseError\n) => {\n // This method returns an error response with the error details.\n return c\n .status(error.code ?? errorCodes.api.INTERNAL_SERVER_ERROR) // Use error code or default to internal server error\n .json({\n status: \"error\",\n message: error.message,\n name: error.name,\n code: error.code,\n details: error.context,\n });\n};\n"],"mappings":"AAAA,SAAS,UAAU,eAAe,+BAA+B;AACjE,SAAS,mBAAmB,kBAAkB;AAGvC,MAAM,iBAAiB,CAAC,GAAoB,SAAc;AAE7D,SAAO,EACF,OAAO,kBAAkB,WAAW,EACpC,KAAK;AAAA,IACF,QAAQ;AAAA,IACR;AAAA,EACJ,CAAC;AACT;AAEO,MAAM,cAAc,CACvB,GACA,UACC;AAED,SAAO,EACF,OAAO,MAAM,QAAQ,WAAW,IAAI,qBAAqB,EACzD,KAAK;AAAA,IACF,QAAQ;AAAA,IACR,SAAS,MAAM;AAAA,IACf,MAAM,MAAM;AAAA,IACZ,MAAM,MAAM;AAAA,IACZ,SAAS,MAAM;AAAA,EACnB,CAAC;AACT;","names":[]}
|
package/dist/index.d.ts
CHANGED
@@ -7,6 +7,7 @@ export { ILoggerConfig } from './types/logger_config.js';
|
|
7
7
|
export { IDocumentConditionalModifications, IQueryFilterOperationParams, IQueryOrderOperationParams, OrderByDirection, WhereFilterOp } from './types/database.js';
|
8
8
|
export { IObserver } from './types/observer.js';
|
9
9
|
export { ChainNativeCurrency, IEventConsumerConfig } from './types/event_consumer_config.js';
|
10
|
+
export { ResponseContext } from './types/response_context.js';
|
10
11
|
export { ApiError, BadRequestError, ForbiddenError, NotFoundError, RateLimitError, TimeoutError, UnauthorizedError } from './errors/api_errors.js';
|
11
12
|
export { DatabaseError } from './errors/database_errors.js';
|
12
13
|
export { ExternalDependencyError } from './errors/external_dependency_error.js';
|
package/dist/types/index.d.ts
CHANGED
@@ -2,5 +2,6 @@ export { ILoggerConfig } from './logger_config.js';
|
|
2
2
|
export { IDocumentConditionalModifications, IQueryFilterOperationParams, IQueryOrderOperationParams, OrderByDirection, WhereFilterOp } from './database.js';
|
3
3
|
export { IObserver } from './observer.js';
|
4
4
|
export { ChainNativeCurrency, IEventConsumerConfig } from './event_consumer_config.js';
|
5
|
+
export { ResponseContext } from './response_context.js';
|
5
6
|
import 'winston';
|
6
7
|
import 'viem';
|
package/dist/types/index.js
CHANGED
package/dist/types/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/types/index.ts"],"sourcesContent":["export * from \"./logger_config\";\nexport * from \"./database\";\nexport * from \"./observer\";\nexport * from \"./event_consumer_config\";\n"],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
|
1
|
+
{"version":3,"sources":["../../src/types/index.ts"],"sourcesContent":["export * from \"./logger_config\";\nexport * from \"./database\";\nexport * from \"./observer\";\nexport * from \"./event_consumer_config\";\nexport * from \"./response_context\";\n"],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
|
@@ -0,0 +1 @@
|
|
1
|
+
//# sourceMappingURL=response_context.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|