mielk-api 1.5.7 → 1.5.9
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/db/pg/connection/transaction.d.ts +2 -0
- package/dist/db/pg/connection/transaction.js +29 -0
- package/dist/db/pg/errors/errorChecks.d.ts +1 -0
- package/dist/db/pg/errors/errorChecks.js +2 -0
- package/dist/db/pg/index.d.ts +7 -4
- package/dist/db/pg/index.js +4 -2
- package/dist/db/pg/types/Executor.d.ts +3 -0
- package/dist/db/pg/types/Executor.js +2 -0
- package/dist/http/httpResponseStatus/HttpResponseStatus.spec.d.ts +1 -0
- package/dist/http/httpResponseStatus/HttpResponseStatus.spec.js +7 -0
- package/dist/http/index.d.ts +1 -1
- package/dist/middlewares/index.d.ts +2 -0
- package/dist/middlewares/rateLimit/types.d.ts +2 -2
- package/dist/middlewares/redis/types.d.ts +3 -2
- package/dist/middlewares/types/Middleware.d.ts +2 -0
- package/dist/middlewares/types/Middleware.js +1 -0
- package/package.json +2 -2
- /package/dist/db/pg/{static → errors}/PostgreErrorCodes.d.ts +0 -0
- /package/dist/db/pg/{static → errors}/PostgreErrorCodes.js +0 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { getPool } from "./pool.js";
|
|
11
|
+
export function withTransaction(fn) {
|
|
12
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
13
|
+
const pool = yield getPool();
|
|
14
|
+
const client = yield pool.connect();
|
|
15
|
+
try {
|
|
16
|
+
yield client.query('BEGIN');
|
|
17
|
+
const result = yield fn(client);
|
|
18
|
+
yield client.query('COMMIT');
|
|
19
|
+
return result;
|
|
20
|
+
}
|
|
21
|
+
catch (err) {
|
|
22
|
+
yield client.query('ROLLBACK');
|
|
23
|
+
throw err;
|
|
24
|
+
}
|
|
25
|
+
finally {
|
|
26
|
+
client.release();
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isUniqueViolation: (err: any) => boolean;
|
package/dist/db/pg/index.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import { POSTGRE_ERRORS } from './static/PostgreErrorCodes.js';
|
|
2
|
-
import { initDb, getPool } from './connection/pool.js';
|
|
3
1
|
import { PostgreDbConfig } from './types/DbConfig.js';
|
|
4
|
-
|
|
2
|
+
import { QueryExecutor } from './types/Executor.js';
|
|
3
|
+
import { initDb, getPool } from './connection/pool.js';
|
|
4
|
+
import { withTransaction } from './connection/transaction.js';
|
|
5
|
+
import { isUniqueViolation } from './errors/errorChecks.js';
|
|
6
|
+
export { PostgreDbConfig, QueryExecutor };
|
|
5
7
|
export { initDb, getPool };
|
|
6
|
-
export {
|
|
8
|
+
export { withTransaction };
|
|
9
|
+
export { isUniqueViolation };
|
package/dist/db/pg/index.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { POSTGRE_ERRORS } from './static/PostgreErrorCodes.js';
|
|
2
1
|
import { initDb, getPool } from './connection/pool.js';
|
|
3
|
-
|
|
2
|
+
import { withTransaction } from './connection/transaction.js';
|
|
3
|
+
import { isUniqueViolation } from './errors/errorChecks.js';
|
|
4
4
|
export { initDb, getPool };
|
|
5
|
+
export { withTransaction };
|
|
6
|
+
export { isUniqueViolation };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/http/index.d.ts
CHANGED
|
@@ -4,6 +4,6 @@ import { HttpStatus } from './types/HttpStatus.js';
|
|
|
4
4
|
import { HttpResponseStatus } from './httpResponseStatus/HttpResponseStatus.js';
|
|
5
5
|
import { success, failure, serverError } from './apiResponse/apiResponse.js';
|
|
6
6
|
export type { ApiResponse };
|
|
7
|
-
export { HttpStatus
|
|
7
|
+
export { HttpStatus, ApiError, ApiSuccess, ApiErrorDetails };
|
|
8
8
|
export { HttpResponseStatus };
|
|
9
9
|
export { success, failure, serverError };
|
|
@@ -3,6 +3,8 @@ import { privateCors } from './cors/privateCors.js';
|
|
|
3
3
|
import { publicCors } from './cors/publicCors.js';
|
|
4
4
|
import { apiKeyAuthorization } from './requestAuth/auth.middleware.js';
|
|
5
5
|
import { validateQueryParams, validateBodyJson } from './zod/validate.js';
|
|
6
|
+
import { Middleware } from './types/Middleware.js';
|
|
6
7
|
export { CorsConfig, initCors, privateCors, publicCors };
|
|
7
8
|
export { apiKeyAuthorization };
|
|
8
9
|
export { validateQueryParams, validateBodyJson };
|
|
10
|
+
export { Middleware };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { NextFunction, Request, Response } from 'express';
|
|
2
1
|
import { RedisLockerConfig, RequestParamsFetcher } from '../redis/types.js';
|
|
3
|
-
|
|
2
|
+
import { Middleware } from '../types/Middleware.js';
|
|
3
|
+
export type RateLimiter = Middleware;
|
|
4
4
|
export interface RateLimitConfig {
|
|
5
5
|
keyPrefix: string;
|
|
6
6
|
keySuffixes: RequestParamsFetcher;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { Request } from "express";
|
|
2
|
+
import { Middleware } from "../types/Middleware.js";
|
|
3
|
+
export type RedisLockChecker = Middleware;
|
|
3
4
|
export type RequestParamsFetcher = (req: Request) => string[];
|
|
4
5
|
export interface RedisLockCheckerConfig {
|
|
5
6
|
keyPrefix: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mielk-api",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.9",
|
|
4
4
|
"keywords": [],
|
|
5
5
|
"author": "mielk",
|
|
6
6
|
"description": "Wrapper for API operations",
|
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
"dependencies": {
|
|
90
90
|
"cors": "^2.8.6",
|
|
91
91
|
"express-rate-limit": "^8.3.1",
|
|
92
|
-
"mielk-fn": "^1.2.
|
|
92
|
+
"mielk-fn": "^1.2.5",
|
|
93
93
|
"pg": "^8.20.0",
|
|
94
94
|
"tunnel-ssh": "^5.2.0"
|
|
95
95
|
}
|
|
File without changes
|
|
File without changes
|