serverless-simple-middleware 0.0.53 → 0.0.56
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/.prettierignore +2 -2
- package/README.md +4 -4
- package/dist/aws/config.d.ts +15 -15
- package/dist/aws/config.js +29 -29
- package/dist/aws/define.d.ts +21 -21
- package/dist/aws/define.js +8 -8
- package/dist/aws/index.d.ts +3 -3
- package/dist/aws/index.js +8 -8
- package/dist/aws/simple.d.ts +44 -44
- package/dist/aws/simple.js +659 -656
- package/dist/index.d.ts +3 -3
- package/dist/index.js +8 -8
- package/dist/middleware/aws.d.ts +25 -25
- package/dist/middleware/aws.js +128 -128
- package/dist/middleware/base.d.ts +54 -54
- package/dist/middleware/base.js +140 -140
- package/dist/middleware/build.d.ts +3 -3
- package/dist/middleware/build.js +234 -234
- package/dist/middleware/index.d.ts +12 -12
- package/dist/middleware/index.js +22 -22
- package/dist/middleware/logger.d.ts +18 -18
- package/dist/middleware/logger.js +71 -71
- package/dist/middleware/mysql.d.ts +44 -44
- package/dist/middleware/mysql.js +289 -289
- package/dist/middleware/trace.d.ts +86 -86
- package/dist/middleware/trace.js +255 -255
- package/dist/utils/index.d.ts +2 -2
- package/dist/utils/index.js +7 -7
- package/dist/utils/logger.d.ts +26 -26
- package/dist/utils/logger.js +73 -73
- package/dist/utils/misc.d.ts +1 -1
- package/dist/utils/misc.js +9 -9
- package/jest.config.js +7 -7
- package/package.json +61 -61
- package/src/aws/config.ts +46 -46
- package/src/aws/define.ts +29 -29
- package/src/aws/index.ts +3 -3
- package/src/aws/simple.ts +529 -531
- package/src/index.ts +3 -3
- package/src/middleware/aws.ts +78 -78
- package/src/middleware/base.ts +164 -164
- package/src/middleware/build.ts +173 -173
- package/src/middleware/index.ts +20 -20
- package/src/middleware/logger.ts +28 -28
- package/src/middleware/mysql.ts +210 -210
- package/src/middleware/trace.ts +269 -269
- package/src/utils/index.ts +2 -2
- package/src/utils/logger.ts +94 -94
- package/src/utils/misc.ts +11 -11
- package/tsconfig.json +15 -15
- package/tslint.json +12 -12
|
@@ -1,71 +1,71 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
extendStatics(d, b);
|
|
11
|
-
function __() { this.constructor = d; }
|
|
12
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
13
|
-
};
|
|
14
|
-
})();
|
|
15
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
16
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
17
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
18
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
19
|
-
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
|
20
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
24
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
25
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
26
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
27
|
-
function step(op) {
|
|
28
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
29
|
-
while (_) try {
|
|
30
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
31
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
32
|
-
switch (op[0]) {
|
|
33
|
-
case 0: case 1: t = op; break;
|
|
34
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
35
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
36
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
37
|
-
default:
|
|
38
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
39
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
40
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
41
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
42
|
-
if (t[2]) _.ops.pop();
|
|
43
|
-
_.trys.pop(); continue;
|
|
44
|
-
}
|
|
45
|
-
op = body.call(thisArg, _);
|
|
46
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
47
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
51
|
-
var utils_1 = require("../utils");
|
|
52
|
-
var base_1 = require("./base");
|
|
53
|
-
var LoggerPlugin = /** @class */ (function (_super) {
|
|
54
|
-
__extends(LoggerPlugin, _super);
|
|
55
|
-
function LoggerPlugin(options) {
|
|
56
|
-
var _this = _super.call(this) || this;
|
|
57
|
-
_this.create = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
58
|
-
var _a, name, level;
|
|
59
|
-
return __generator(this, function (_b) {
|
|
60
|
-
_a = this.options, name = _a.name, level = _a.level;
|
|
61
|
-
return [2 /*return*/, { logger: utils_1.getLogger(name, level) }];
|
|
62
|
-
});
|
|
63
|
-
}); };
|
|
64
|
-
_this.options = options;
|
|
65
|
-
return _this;
|
|
66
|
-
}
|
|
67
|
-
return LoggerPlugin;
|
|
68
|
-
}(base_1.HandlerPluginBase));
|
|
69
|
-
exports.LoggerPlugin = LoggerPlugin;
|
|
70
|
-
var build = function (options) { return new LoggerPlugin(options); };
|
|
71
|
-
exports.default = build;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
extendStatics(d, b);
|
|
11
|
+
function __() { this.constructor = d; }
|
|
12
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
15
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
16
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
17
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
18
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
19
|
+
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
|
20
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
24
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
25
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
26
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
27
|
+
function step(op) {
|
|
28
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
29
|
+
while (_) try {
|
|
30
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
31
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
32
|
+
switch (op[0]) {
|
|
33
|
+
case 0: case 1: t = op; break;
|
|
34
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
35
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
36
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
37
|
+
default:
|
|
38
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
39
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
40
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
41
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
42
|
+
if (t[2]) _.ops.pop();
|
|
43
|
+
_.trys.pop(); continue;
|
|
44
|
+
}
|
|
45
|
+
op = body.call(thisArg, _);
|
|
46
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
47
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
51
|
+
var utils_1 = require("../utils");
|
|
52
|
+
var base_1 = require("./base");
|
|
53
|
+
var LoggerPlugin = /** @class */ (function (_super) {
|
|
54
|
+
__extends(LoggerPlugin, _super);
|
|
55
|
+
function LoggerPlugin(options) {
|
|
56
|
+
var _this = _super.call(this) || this;
|
|
57
|
+
_this.create = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
58
|
+
var _a, name, level;
|
|
59
|
+
return __generator(this, function (_b) {
|
|
60
|
+
_a = this.options, name = _a.name, level = _a.level;
|
|
61
|
+
return [2 /*return*/, { logger: utils_1.getLogger(name, level) }];
|
|
62
|
+
});
|
|
63
|
+
}); };
|
|
64
|
+
_this.options = options;
|
|
65
|
+
return _this;
|
|
66
|
+
}
|
|
67
|
+
return LoggerPlugin;
|
|
68
|
+
}(base_1.HandlerPluginBase));
|
|
69
|
+
exports.LoggerPlugin = LoggerPlugin;
|
|
70
|
+
var build = function (options) { return new LoggerPlugin(options); };
|
|
71
|
+
exports.default = build;
|
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
import * as mysql from 'mysql';
|
|
2
|
-
import { HandlerAuxBase, HandlerPluginBase } from './base';
|
|
3
|
-
export interface MySQLPluginOptions {
|
|
4
|
-
config: mysql.ConnectionConfig;
|
|
5
|
-
schema?: {
|
|
6
|
-
eager?: boolean;
|
|
7
|
-
ignoreError?: boolean;
|
|
8
|
-
database?: string;
|
|
9
|
-
tables?: {
|
|
10
|
-
[tableName: string]: string;
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
export declare class ConnectionProxy {
|
|
15
|
-
private pluginConfig;
|
|
16
|
-
private connection?;
|
|
17
|
-
private initialized;
|
|
18
|
-
private dbName?;
|
|
19
|
-
constructor(config: MySQLPluginOptions);
|
|
20
|
-
query: <T>(sql: string, params?: any[] | undefined) => Promise<T | undefined>;
|
|
21
|
-
fetch: <T>(sql: string, params?: any[] | undefined) => Promise<T[]>;
|
|
22
|
-
fetchOne: <T>(sql: string, params?: any[] | undefined, defaultValue?: T | undefined) => Promise<T>;
|
|
23
|
-
beginTransaction: () => Promise<void>;
|
|
24
|
-
commit: () => Promise<void>;
|
|
25
|
-
rollback: () => Promise<void>;
|
|
26
|
-
clearConnection: () => void;
|
|
27
|
-
onPluginCreated: () => Promise<void>;
|
|
28
|
-
private prepareConnection;
|
|
29
|
-
private changeDatabase;
|
|
30
|
-
private tryToInitializeSchema;
|
|
31
|
-
}
|
|
32
|
-
export interface MySQLPluginAux extends HandlerAuxBase {
|
|
33
|
-
db: ConnectionProxy;
|
|
34
|
-
}
|
|
35
|
-
export declare class MySQLPlugin extends HandlerPluginBase<MySQLPluginAux> {
|
|
36
|
-
private proxy;
|
|
37
|
-
constructor(options: MySQLPluginOptions);
|
|
38
|
-
create: () => Promise<{
|
|
39
|
-
db: ConnectionProxy;
|
|
40
|
-
}>;
|
|
41
|
-
end: () => void;
|
|
42
|
-
}
|
|
43
|
-
declare const build: (options: MySQLPluginOptions) => MySQLPlugin;
|
|
44
|
-
export default build;
|
|
1
|
+
import * as mysql from 'mysql';
|
|
2
|
+
import { HandlerAuxBase, HandlerPluginBase } from './base';
|
|
3
|
+
export interface MySQLPluginOptions {
|
|
4
|
+
config: mysql.ConnectionConfig;
|
|
5
|
+
schema?: {
|
|
6
|
+
eager?: boolean;
|
|
7
|
+
ignoreError?: boolean;
|
|
8
|
+
database?: string;
|
|
9
|
+
tables?: {
|
|
10
|
+
[tableName: string]: string;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export declare class ConnectionProxy {
|
|
15
|
+
private pluginConfig;
|
|
16
|
+
private connection?;
|
|
17
|
+
private initialized;
|
|
18
|
+
private dbName?;
|
|
19
|
+
constructor(config: MySQLPluginOptions);
|
|
20
|
+
query: <T>(sql: string, params?: any[] | undefined) => Promise<T | undefined>;
|
|
21
|
+
fetch: <T>(sql: string, params?: any[] | undefined) => Promise<T[]>;
|
|
22
|
+
fetchOne: <T>(sql: string, params?: any[] | undefined, defaultValue?: T | undefined) => Promise<T>;
|
|
23
|
+
beginTransaction: () => Promise<void>;
|
|
24
|
+
commit: () => Promise<void>;
|
|
25
|
+
rollback: () => Promise<void>;
|
|
26
|
+
clearConnection: () => void;
|
|
27
|
+
onPluginCreated: () => Promise<void>;
|
|
28
|
+
private prepareConnection;
|
|
29
|
+
private changeDatabase;
|
|
30
|
+
private tryToInitializeSchema;
|
|
31
|
+
}
|
|
32
|
+
export interface MySQLPluginAux extends HandlerAuxBase {
|
|
33
|
+
db: ConnectionProxy;
|
|
34
|
+
}
|
|
35
|
+
export declare class MySQLPlugin extends HandlerPluginBase<MySQLPluginAux> {
|
|
36
|
+
private proxy;
|
|
37
|
+
constructor(options: MySQLPluginOptions);
|
|
38
|
+
create: () => Promise<{
|
|
39
|
+
db: ConnectionProxy;
|
|
40
|
+
}>;
|
|
41
|
+
end: () => void;
|
|
42
|
+
}
|
|
43
|
+
declare const build: (options: MySQLPluginOptions) => MySQLPlugin;
|
|
44
|
+
export default build;
|