@koeroesi86/node-lambda-invoke 1.0.21-d1fa702 → 26.10.36903641712-master
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 +4 -4
- package/dist/classes/FileStorage.d.ts +18 -0
- package/dist/classes/FileStorage.js +62 -0
- package/dist/classes/FileStorage.js.map +1 -0
- package/dist/classes/IPCStorage.d.ts +26 -0
- package/dist/classes/IPCStorage.js +208 -0
- package/dist/classes/IPCStorage.js.map +1 -0
- package/dist/classes/Lambda.d.ts +30 -0
- package/dist/classes/Lambda.js +100 -0
- package/dist/classes/Lambda.js.map +1 -0
- package/dist/classes/LambdaPool.d.ts +19 -0
- package/dist/classes/LambdaPool.js +74 -0
- package/dist/classes/LambdaPool.js.map +1 -0
- package/dist/classes/RequestEvent.d.ts +13 -0
- package/dist/classes/RequestEvent.js +6 -0
- package/dist/classes/RequestEvent.js.map +1 -0
- package/dist/classes/ResponseEvent.d.ts +8 -0
- package/dist/classes/ResponseEvent.js +6 -0
- package/dist/classes/ResponseEvent.js.map +1 -0
- package/dist/classes/Worker.d.ts +20 -0
- package/dist/classes/Worker.js +77 -0
- package/dist/classes/Worker.js.map +1 -0
- package/dist/constants/index.d.ts +5 -0
- package/dist/constants/index.js +10 -0
- package/dist/constants/index.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/middlewares/http.d.ts +5 -0
- package/dist/middlewares/http.js +75 -0
- package/dist/middlewares/http.js.map +1 -0
- package/dist/middlewares/invoke.d.ts +1 -0
- package/dist/middlewares/invoke.js +48 -0
- package/dist/middlewares/invoke.js.map +1 -0
- package/dist/middlewares/stdoutListener.d.ts +4 -0
- package/dist/middlewares/stdoutListener.js +27 -0
- package/dist/middlewares/stdoutListener.js.map +1 -0
- package/dist/registry/communication.json +12 -0
- package/dist/registry/index.d.ts +2 -0
- package/dist/registry/index.js +19 -0
- package/dist/registry/index.js.map +1 -0
- package/dist/types.d.ts +36 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/sendToParent.d.ts +3 -0
- package/dist/utils/sendToParent.js +10 -0
- package/dist/utils/sendToParent.js.map +1 -0
- package/example/example.js +1 -1
- package/package.json +28 -11
- package/.travis.yml +0 -16
- package/classes/FileStorage.js +0 -114
- package/classes/IPCStorage.js +0 -216
- package/classes/Lambda.js +0 -124
- package/classes/LambdaPool.js +0 -78
- package/classes/RequestEvent.js +0 -15
- package/classes/ResponseEvent.js +0 -12
- package/classes/Worker.js +0 -93
- package/constants/index.js +0 -8
- package/index.js +0 -9
- package/middlewares/http.js +0 -111
- package/middlewares/invoke.js +0 -50
- package/middlewares/stdoutListener.js +0 -27
- package/registry/communication.json +0 -12
- package/scripts/version.js +0 -10
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ResponseEvent.js","sourceRoot":"","sources":["../../src/classes/ResponseEvent.ts"],"names":[],"mappings":";;AAEA,MAAM,aAAa;CAKlB;AAED,kBAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ChildProcess, Serializable, SpawnOptions } from 'child_process';
|
|
2
|
+
import type { Listener } from '../types';
|
|
3
|
+
declare class Worker {
|
|
4
|
+
readonly workerPath: string;
|
|
5
|
+
instance?: ChildProcess;
|
|
6
|
+
constructor(workerPath: string, options?: SpawnOptions);
|
|
7
|
+
set onmessage(onmessage: Listener);
|
|
8
|
+
set onerror(onerror: Listener);
|
|
9
|
+
get stdout(): import("stream").Readable | null | undefined;
|
|
10
|
+
get stderr(): import("stream").Readable | null | undefined;
|
|
11
|
+
addEventListener(event: string, listener: Listener): void;
|
|
12
|
+
addEventListenerOnce(event: string, listener: Listener): void;
|
|
13
|
+
on(event: string, listener: Listener): void;
|
|
14
|
+
off(event: string, listener: Listener): void;
|
|
15
|
+
send(message: Serializable, cb?: (error: Error | null) => void): void;
|
|
16
|
+
removeEventListener(event: string, listener: Listener): void;
|
|
17
|
+
terminate(): void;
|
|
18
|
+
postMessage(message: Serializable, cb?: (error: Error | null) => void): void;
|
|
19
|
+
}
|
|
20
|
+
export default Worker;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const child_process_1 = require("child_process");
|
|
4
|
+
// TODO: move this to separate package
|
|
5
|
+
class Worker {
|
|
6
|
+
workerPath;
|
|
7
|
+
instance;
|
|
8
|
+
constructor(workerPath, options = {}) {
|
|
9
|
+
this.workerPath = workerPath;
|
|
10
|
+
const instance = (0, child_process_1.spawn)('node', [...this.workerPath.split(' ')], {
|
|
11
|
+
stdio: ['pipe', 'pipe', 'pipe', 'ipc'],
|
|
12
|
+
...options,
|
|
13
|
+
});
|
|
14
|
+
this.instance = instance;
|
|
15
|
+
if (instance.stdout) {
|
|
16
|
+
const messageListener = (data) => {
|
|
17
|
+
console.info(data.toString().trim());
|
|
18
|
+
};
|
|
19
|
+
instance.stdout.on('data', messageListener);
|
|
20
|
+
}
|
|
21
|
+
instance.once('close', () => {
|
|
22
|
+
delete this.instance;
|
|
23
|
+
});
|
|
24
|
+
this.addEventListener = this.addEventListener.bind(this);
|
|
25
|
+
this.removeEventListener = this.removeEventListener.bind(this);
|
|
26
|
+
this.terminate = this.terminate.bind(this);
|
|
27
|
+
this.postMessage = this.postMessage.bind(this);
|
|
28
|
+
this.send = this.send.bind(this);
|
|
29
|
+
}
|
|
30
|
+
set onmessage(onmessage) {
|
|
31
|
+
this.addEventListener('message', onmessage);
|
|
32
|
+
}
|
|
33
|
+
set onerror(onerror) {
|
|
34
|
+
this.addEventListener('error', onerror);
|
|
35
|
+
}
|
|
36
|
+
get stdout() {
|
|
37
|
+
return this.instance?.stdout;
|
|
38
|
+
}
|
|
39
|
+
get stderr() {
|
|
40
|
+
return this.instance?.stderr;
|
|
41
|
+
}
|
|
42
|
+
addEventListener(event, listener) {
|
|
43
|
+
if (this.instance)
|
|
44
|
+
this.instance.on(event, listener);
|
|
45
|
+
}
|
|
46
|
+
addEventListenerOnce(event, listener) {
|
|
47
|
+
if (this.instance)
|
|
48
|
+
this.instance.once(event, listener);
|
|
49
|
+
}
|
|
50
|
+
on(event, listener) {
|
|
51
|
+
this.addEventListener(event, listener);
|
|
52
|
+
}
|
|
53
|
+
off(event, listener) {
|
|
54
|
+
this.removeEventListener(event, listener);
|
|
55
|
+
}
|
|
56
|
+
send(message, cb = () => { }) {
|
|
57
|
+
this.postMessage(message, cb);
|
|
58
|
+
}
|
|
59
|
+
removeEventListener(event, listener) {
|
|
60
|
+
if (this.instance && this.instance.off)
|
|
61
|
+
this.instance.off(event, listener);
|
|
62
|
+
}
|
|
63
|
+
// from EventTarget prototype, if needed
|
|
64
|
+
// dispatchEvent() {
|
|
65
|
+
//
|
|
66
|
+
// }
|
|
67
|
+
terminate() {
|
|
68
|
+
if (this.instance)
|
|
69
|
+
this.instance.kill('SIGINT');
|
|
70
|
+
}
|
|
71
|
+
postMessage(message, cb = () => { }) {
|
|
72
|
+
if (this.instance)
|
|
73
|
+
this.instance.send(message, cb);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
exports.default = Worker;
|
|
77
|
+
//# sourceMappingURL=Worker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Worker.js","sourceRoot":"","sources":["../../src/classes/Worker.ts"],"names":[],"mappings":";;AAAA,iDAAsC;AAItC,sCAAsC;AACtC,MAAM,MAAM;IACD,UAAU,CAAS;IAC5B,QAAQ,CAAgB;IAExB,YAAY,UAAkB,EAAE,UAAwB,EAAE;QACxD,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,MAAM,QAAQ,GAAG,IAAA,qBAAK,EAAC,MAAM,EAAE,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE;YAC9D,KAAK,EAAE,CAAC,MAAM,EAAE,M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,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IACrD,CAAC;CACF;AAED,kBAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** folder of the package, both from src/ and dist/ */
|
|
2
|
+
export declare const PACKAGE_ROOT: string;
|
|
3
|
+
export declare const EVENT_STARTED = "LAMBDA_EVENT_STARTED";
|
|
4
|
+
export declare const EVENT_REQUEST = "LAMBDA_EVENT_REQUEST";
|
|
5
|
+
export declare const EVENT_RESPONSE = "LAMBDA_EVENT_RESPONSE";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EVENT_RESPONSE = exports.EVENT_REQUEST = exports.EVENT_STARTED = exports.PACKAGE_ROOT = void 0;
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
/** folder of the package, both from src/ and dist/ */
|
|
6
|
+
exports.PACKAGE_ROOT = (0, path_1.resolve)(__dirname, '../..');
|
|
7
|
+
exports.EVENT_STARTED = 'LAMBDA_EVENT_STARTED';
|
|
8
|
+
exports.EVENT_REQUEST = 'LAMBDA_EVENT_REQUEST';
|
|
9
|
+
exports.EVENT_RESPONSE = 'LAMBDA_EVENT_RESPONSE';
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/constants/index.ts"],"names":[],"mappings":";;;AAAA,+BAA+B;AAE/B,sDAAsD;AACzC,QAAA,YAAY,GAAG,IAAA,cAAO,EAAC,SAAS,EAAE,OAAO,CAAC,CAAC;AAE3C,QAAA,aAAa,GAAG,sBAAsB,CAAC;AAEvC,QAAA,aAAa,GAAG,sBAAsB,CAAC;AAEvC,QAAA,cAAc,GAAG,uBAAuB,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import httpMiddleware from './middlewares/http';
|
|
2
|
+
import Lambda from './classes/Lambda';
|
|
3
|
+
import FileStorage from './classes/FileStorage';
|
|
4
|
+
import IPCStorage from './classes/IPCStorage';
|
|
5
|
+
import Worker from './classes/Worker';
|
|
6
|
+
export { httpMiddleware, Lambda, FileStorage, IPCStorage, Worker };
|
|
7
|
+
export type { HttpMiddleware } from './middlewares/http';
|
|
8
|
+
export type { Communication, HttpMiddlewareOptions, Logger, Storage, StorageDriverConstructor, StorageInstance } from './types';
|
|
9
|
+
export type { default as RequestEvent } from './classes/RequestEvent';
|
|
10
|
+
export type { default as ResponseEvent } from './classes/ResponseEvent';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Worker = exports.IPCStorage = exports.FileStorage = exports.Lambda = exports.httpMiddleware = void 0;
|
|
7
|
+
const http_1 = __importDefault(require("./middlewares/http"));
|
|
8
|
+
exports.httpMiddleware = http_1.default;
|
|
9
|
+
const Lambda_1 = __importDefault(require("./classes/Lambda"));
|
|
10
|
+
exports.Lambda = Lambda_1.default;
|
|
11
|
+
const FileStorage_1 = __importDefault(require("./classes/FileStorage"));
|
|
12
|
+
exports.FileStorage = FileStorage_1.default;
|
|
13
|
+
const IPCStorage_1 = __importDefault(require("./classes/IPCStorage"));
|
|
14
|
+
exports.IPCStorage = IPCStorage_1.default;
|
|
15
|
+
const Worker_1 = __importDefault(require("./classes/Worker"));
|
|
16
|
+
exports.Worker = Worker_1.default;
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,8DAAgD;AAMvC,yBANF,cAAc,CAME;AALvB,8DAAsC;AAKb,iBALlB,gBAAM,CAKkB;AAJ/B,wEAAgD;AAIf,sBAJ1B,qBAAW,CAI0B;AAH5C,sEAA8C;AAGA,qBAHvC,oBAAU,CAGuC;AAFxD,8DAAsC;AAEoB,iBAFnD,gBAAM,CAEmD"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { IncomingMessage, ServerResponse } from 'http';
|
|
2
|
+
import type { HttpMiddlewareOptions } from '../types';
|
|
3
|
+
export type HttpMiddleware = (request: IncomingMessage, response: ServerResponse, next?: () => void) => void;
|
|
4
|
+
declare function createHttpMiddleware(options: HttpMiddlewareOptions): HttpMiddleware;
|
|
5
|
+
export default createHttpMiddleware;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const uuid_1 = __importDefault(require("uuid"));
|
|
7
|
+
const url_1 = __importDefault(require("url"));
|
|
8
|
+
const LambdaPool_1 = __importDefault(require("../classes/LambdaPool"));
|
|
9
|
+
const RequestEvent_1 = __importDefault(require("../classes/RequestEvent"));
|
|
10
|
+
const registry_1 = require("../registry");
|
|
11
|
+
let overallLimit = 3000;
|
|
12
|
+
const writeResponse = (response, responseEvent) => {
|
|
13
|
+
if (!responseEvent.statusCode)
|
|
14
|
+
return;
|
|
15
|
+
response.writeHead(responseEvent.statusCode, responseEvent.headers);
|
|
16
|
+
if (!responseEvent.body) {
|
|
17
|
+
response.end();
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const bufferEncoding = responseEvent.isBase64Encoded ? 'base64' : 'utf8';
|
|
21
|
+
response.end(Buffer.from(responseEvent.body, bufferEncoding));
|
|
22
|
+
};
|
|
23
|
+
function createHttpMiddleware(options) {
|
|
24
|
+
const { lambdaPath, handlerKey = 'handler', logger = () => { }, limit = overallLimit, communication = {} } = options;
|
|
25
|
+
const currentCommunication = !communication.type ? { type: 'ipc' } : { ...communication };
|
|
26
|
+
const storagePath = (0, registry_1.isRegistered)(currentCommunication.type ?? '') ? (0, registry_1.getRegisteredPath)(currentCommunication.type) : currentCommunication.path;
|
|
27
|
+
// TODO: tmp folders
|
|
28
|
+
if (!storagePath) {
|
|
29
|
+
return (req, res, next) => {
|
|
30
|
+
next?.();
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
if (limit) {
|
|
34
|
+
overallLimit = limit;
|
|
35
|
+
}
|
|
36
|
+
const StorageDriver = require(storagePath);
|
|
37
|
+
if (StorageDriver.start)
|
|
38
|
+
StorageDriver.start();
|
|
39
|
+
const lambdaPool = new LambdaPool_1.default({ logger, communication: currentCommunication });
|
|
40
|
+
return (request, response) => {
|
|
41
|
+
const { query: queryStringParameters, pathname: path } = url_1.default.parse(request.url ?? '', true);
|
|
42
|
+
const requestEvent = new RequestEvent_1.default();
|
|
43
|
+
requestEvent.httpMethod = request.method?.toUpperCase() ?? '';
|
|
44
|
+
requestEvent.path = path ?? '';
|
|
45
|
+
requestEvent.queryStringParameters = queryStringParameters;
|
|
46
|
+
requestEvent.headers = request.headers;
|
|
47
|
+
const requestId = uuid_1.default.v4();
|
|
48
|
+
let storage;
|
|
49
|
+
logger('Invoking lambda', `${lambdaPath}#${handlerKey}`);
|
|
50
|
+
const closeListener = () => {
|
|
51
|
+
if (!response.writableEnded)
|
|
52
|
+
response.end();
|
|
53
|
+
if (storage)
|
|
54
|
+
storage.destroy();
|
|
55
|
+
};
|
|
56
|
+
const handleRequest = async () => {
|
|
57
|
+
const lambdaInstance = await lambdaPool.getLambda(lambdaPath, handlerKey);
|
|
58
|
+
lambdaInstance.addEventListenerOnce('close', closeListener);
|
|
59
|
+
const currentStorage = new StorageDriver(requestId, lambdaInstance);
|
|
60
|
+
storage = currentStorage;
|
|
61
|
+
const responseEvent = await new Promise((res) => lambdaInstance.invoke(requestId, requestEvent, res));
|
|
62
|
+
writeResponse(response, responseEvent);
|
|
63
|
+
lambdaInstance.removeEventListener('close', closeListener);
|
|
64
|
+
return currentStorage.destroy();
|
|
65
|
+
};
|
|
66
|
+
handleRequest().catch((err) => {
|
|
67
|
+
logger(err);
|
|
68
|
+
response.writeHead(500);
|
|
69
|
+
response.write('Something went wrong.');
|
|
70
|
+
response.end();
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
exports.default = createHttpMiddleware;
|
|
75
|
+
//# sourceMappingURL=http.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../../src/middlewares/http.ts"],"names":[],"mappings":";;;;;AAAA,gDAAwB;AACxB,8CAAsB;AAEtB,uEAA+C;AAC/C,2EAAmD;AACnD,0CAA8D;AAM9D,IAAI,YAAY,GAAG,IAAI,CAAC;AAExB,MAAM,aAAa,GAAG,CAAC,QAAwB,EAAE,aAA4B,EAAE,EAAE;IAC/E,IAAI,CAAC,aAAa,CAAC,UAAU;QAAE,OAAO;IAEtC,QAAQ,CAAC,SAAS,CAAC,aAAa,CAAC,UAAU,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;IAEpE,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC;QACxB,QAAQ,CAAC,GAAG,EAAE,CAAC;QACf,OAAO;IACT,CAAC;IAED,MAAM,cAAc,GAAG,aAAa,CAAC,eAAe,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC;IACzE,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC,CAAC;AAChE,CAAC,CAAC;AAEF,SAAS,oBAAoB,CAAC,OAA8B;IAC1D,MAAM,EAAE,UAAU,EAAE,UAAU,GAAG,SAAS,EAAE,MAAM,GAAG,GAAG,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,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;YACxB,QAAQ,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC;YACxC,QAAQ,CAAC,GAAG,EAAE,CAAC;QACjB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC;AAED,kBAAe,oBAAoB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const ResponseEvent_1 = __importDefault(require("../classes/ResponseEvent"));
|
|
7
|
+
const constants_1 = require("../constants");
|
|
8
|
+
const registry_1 = require("../registry");
|
|
9
|
+
const sendToParent_1 = __importDefault(require("../utils/sendToParent"));
|
|
10
|
+
const { LAMBDA = './testLambda.js', HANDLER = 'handler', COMMUNICATION = '{}' } = process.env;
|
|
11
|
+
const lambdaModule = require(LAMBDA);
|
|
12
|
+
const lambdaHandler = lambdaModule[HANDLER];
|
|
13
|
+
const communication = JSON.parse(COMMUNICATION);
|
|
14
|
+
const Storage = require((0, registry_1.getRegisteredPath)(communication.type));
|
|
15
|
+
setTimeout(() => {
|
|
16
|
+
process.exit(0);
|
|
17
|
+
}, 15 * 60 * 1000); // setting to default 15 minutes AWS timeout 15 * 60 * 1000
|
|
18
|
+
const getErrorBody = (error) => (typeof error === 'object' && error !== null && 'body' in error && error.body ? `${error.body}` : `${error}`);
|
|
19
|
+
function messageListener(event) {
|
|
20
|
+
if (event.type !== constants_1.EVENT_REQUEST || event.id === undefined)
|
|
21
|
+
return;
|
|
22
|
+
const { id } = event;
|
|
23
|
+
const storage = new Storage(id, process);
|
|
24
|
+
Promise.resolve()
|
|
25
|
+
.then(() => storage.getRequest())
|
|
26
|
+
.then((requestEvent) => new Promise((resolve) => {
|
|
27
|
+
lambdaHandler(requestEvent, {}, (error, response = new ResponseEvent_1.default()) => {
|
|
28
|
+
const responseEvent = new ResponseEvent_1.default();
|
|
29
|
+
if (error) {
|
|
30
|
+
responseEvent.statusCode = 500;
|
|
31
|
+
responseEvent.body = getErrorBody(error);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
Object.assign(responseEvent, response);
|
|
35
|
+
}
|
|
36
|
+
resolve(responseEvent);
|
|
37
|
+
});
|
|
38
|
+
}))
|
|
39
|
+
.then((responseEvent) => storage.setResponse(responseEvent))
|
|
40
|
+
.then(() => (0, sendToParent_1.default)({ type: constants_1.EVENT_RESPONSE, id }));
|
|
41
|
+
}
|
|
42
|
+
process.on('message', (event) => {
|
|
43
|
+
if (typeof event === 'object' && event !== null) {
|
|
44
|
+
messageListener(event);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
(0, sendToParent_1.default)({ type: constants_1.EVENT_STARTED });
|
|
48
|
+
//# sourceMappingURL=invoke.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invoke.js","sourceRoot":"","sources":["../../src/middlewares/invoke.ts"],"names":[],"mappings":";;;;;AAAA,6EAAqD;AACrD,4CAA4E;AAC5E,0CAAgD;AAChD,yEAAiD;AAMjD,MAAM,EAAE,MAAM,GAAG,iBAAiB,EAAE,OAAO,GAAG,SAAS,EAAE,aAAa,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC;AAE9F,MAAM,YAAY,GAAkC,OAAO,CAAC,MAAM,CAAC,CAAC;AACpE,MAAM,aAAa,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;AAC5C,MAAM,aAAa,GAAkB,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;AAC/D,MAAM,OAAO,GAA6B,OAAO,CAAC,IAAA,4BAAiB,EAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC;AAEzF,UAAU,CAAC,GAAG,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,CAAC;QACzB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CACL;SACA,IAAI,CAAC,CAAC,aAAa,EAAE,EAAE,CAAC,OAAO,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC;SAC3D,IAAI,CAAC,GAAG,EAAE,CAAC,IAAA,sBAAY,EAAC,EAAE,IAAI,EAAE,0BAAc,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;AAC5D,CAAC;AAED,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE;IAC9B,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAChD,eAAe,CAAC,KAAK,CAAC,CAAC;IACzB,CAAC;AACH,CAAC,CAAC,CAAC;AAEH,IAAA,sBAAY,EAAC,EAAE,IAAI,EAAE,yBAAa,EAAE,CAAC,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const moment_1 = __importDefault(require("moment"));
|
|
7
|
+
const getDate = () => (0, moment_1.default)().format('YYYY-MM-DD HH:mm:ss.SS');
|
|
8
|
+
const stdoutListener = (lambdaInstance, logger = () => { }) => {
|
|
9
|
+
const messageListener = (data) => {
|
|
10
|
+
logger(`[${getDate()}] ${data.toString().trim()}`);
|
|
11
|
+
};
|
|
12
|
+
if (lambdaInstance.stdout) {
|
|
13
|
+
lambdaInstance.stdout.off('data', messageListener);
|
|
14
|
+
lambdaInstance.stdout.on('data', messageListener);
|
|
15
|
+
}
|
|
16
|
+
if (lambdaInstance.stderr) {
|
|
17
|
+
lambdaInstance.stderr.off('data', messageListener);
|
|
18
|
+
lambdaInstance.stderr.on('data', messageListener);
|
|
19
|
+
}
|
|
20
|
+
const closeListener = (code) => {
|
|
21
|
+
if (code)
|
|
22
|
+
logger(`[${getDate()}] child process exited with code ${code}`);
|
|
23
|
+
};
|
|
24
|
+
lambdaInstance.addEventListenerOnce('close', closeListener);
|
|
25
|
+
};
|
|
26
|
+
exports.default = stdoutListener;
|
|
27
|
+
//# sourceMappingURL=stdoutListener.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stdoutListener.js","sourceRoot":"","sources":["../../src/middlewares/stdoutListener.ts"],"names":[],"mappings":";;;;;AAAA,oDAA4B;AAI5B,MAAM,OAAO,GAAG,GAAG,EAAE,CAAC,IAAA,gBAAM,GAAE,CAAC,MAAM,CAAC,wBAAwB,CAAC,CAAC;AAEhE,MAAM,cAAc,GAAG,CAAC,cAAsB,EAAE,SAAiB,GAAG,EAAE,GAAE,CAAC,EAAE,EAAE;IAC3E,MAAM,eAAe,GAAG,CAAC,IAAqB,EAAE,EAAE;QAChD,MAAM,CAAC,IAAI,OAAO,EAAE,KAAK,IAAI,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IACrD,CAAC,CAAC;IACF,IAAI,cAAc,CAAC,MAAM,EAAE,CAAC;QAC1B,cAAc,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;QACnD,cAAc,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IACpD,CAAC;IACD,IAAI,cAAc,CAAC,MAAM,EAAE,CAAC;QAC1B,cAAc,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;QACnD,cAAc,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IACpD,CAAC;IAED,MAAM,aAAa,GAAG,CAAC,IAAmB,EAAE,EAAE;QAC5C,IAAI,IAAI;YAAE,MAAM,CAAC,IAAI,OAAO,EAAE,oCAAoC,IAAI,EAAE,CAAC,CAAC;IAC5E,CAAC,CAAC;IACF,cAAc,CAAC,oBAAoB,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;AAC9D,CAAC,CAAC;AAEF,kBAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getRegisteredPath = exports.isRegistered = void 0;
|
|
7
|
+
const communication_json_1 = __importDefault(require("./communication.json"));
|
|
8
|
+
const registry = communication_json_1.default;
|
|
9
|
+
const isRegistered = (type) => type in registry;
|
|
10
|
+
exports.isRegistered = isRegistered;
|
|
11
|
+
const getRegisteredPath = (type) => {
|
|
12
|
+
const entry = type === undefined ? undefined : registry[type];
|
|
13
|
+
if (!entry) {
|
|
14
|
+
throw new Error(`Unknown communication type: ${type}`);
|
|
15
|
+
}
|
|
16
|
+
return entry.js.path;
|
|
17
|
+
};
|
|
18
|
+
exports.getRegisteredPath = getRegisteredPath;
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/registry/index.ts"],"names":[],"mappings":";;;;;;AAAA,8EAAyD;AAMzD,MAAM,QAAQ,GAAkC,4BAAqB,CAAC;AAE/D,MAAM,YAAY,GAAG,CAAC,IAAY,EAAW,EAAE,CAAC,IAAI,IAAI,QAAQ,CAAC;AAA3D,QAAA,YAAY,gBAA+C;AAEjE,MAAM,iBAAiB,GAAG,CAAC,IAAwB,EAAU,EAAE;IACpE,MAAM,KAAK,GAAG,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAE9D,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,+BAA+B,IAAI,EAAE,CAAC,CAAC;IACzD,CAAC;IAED,OAAO,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC;AACvB,CAAC,CAAC;AARW,QAAA,iBAAiB,qBAQ5B"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type Lambda from './classes/Lambda';
|
|
2
|
+
import type RequestEvent from './classes/RequestEvent';
|
|
3
|
+
import type ResponseEvent from './classes/ResponseEvent';
|
|
4
|
+
import type Worker from './classes/Worker';
|
|
5
|
+
/** a listener of any event of an EventEmitter */
|
|
6
|
+
export type Listener = Parameters<NodeJS.EventEmitter['on']>[1];
|
|
7
|
+
export type Logger = (...args: unknown[]) => void;
|
|
8
|
+
export interface Communication {
|
|
9
|
+
type?: string;
|
|
10
|
+
path?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface HttpMiddlewareOptions {
|
|
13
|
+
lambdaPath: string;
|
|
14
|
+
handlerKey?: string;
|
|
15
|
+
logger?: Logger;
|
|
16
|
+
limit?: number;
|
|
17
|
+
communication?: Communication;
|
|
18
|
+
}
|
|
19
|
+
/** an event emitted by a lambda worker */
|
|
20
|
+
export interface LambdaEvent {
|
|
21
|
+
type?: string;
|
|
22
|
+
id?: string;
|
|
23
|
+
}
|
|
24
|
+
/** what a storage can be attached to: the worker itself, a lambda or the current process */
|
|
25
|
+
export type StorageInstance = Lambda | Worker | NodeJS.Process;
|
|
26
|
+
export interface Storage {
|
|
27
|
+
setResponse: (response: ResponseEvent) => Promise<unknown>;
|
|
28
|
+
getResponse: () => Promise<ResponseEvent>;
|
|
29
|
+
setRequest: (request: RequestEvent) => Promise<unknown>;
|
|
30
|
+
getRequest: () => Promise<RequestEvent>;
|
|
31
|
+
destroy: () => Promise<unknown>;
|
|
32
|
+
}
|
|
33
|
+
export interface StorageDriverConstructor {
|
|
34
|
+
new (id: string, instance: StorageInstance): Storage;
|
|
35
|
+
start?: () => void;
|
|
36
|
+
}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const sendToParent = (message) => {
|
|
4
|
+
if (!process.send) {
|
|
5
|
+
throw new Error('There is no IPC channel to the parent process.');
|
|
6
|
+
}
|
|
7
|
+
process.send(message);
|
|
8
|
+
};
|
|
9
|
+
exports.default = sendToParent;
|
|
10
|
+
//# sourceMappingURL=sendToParent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sendToParent.js","sourceRoot":"","sources":["../../src/utils/sendToParent.ts"],"names":[],"mappings":";;AAEA,MAAM,YAAY,GAAG,CAAC,OAAqB,EAAE,EAAE;IAC7C,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;QAClB,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;IACpE,CAAC;IAED,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AACxB,CAAC,CAAC;AAEF,kBAAe,YAAY,CAAC"}
|
package/example/example.js
CHANGED
package/package.json
CHANGED
|
@@ -1,27 +1,44 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@koeroesi86/node-lambda-invoke",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "26.10.36903641712-master",
|
|
4
4
|
"description": "A local Lambda implementation",
|
|
5
|
-
"main": "index.js",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Krisztian Korosi",
|
|
8
8
|
"url": "https://github.com/Koeroesi86"
|
|
9
9
|
},
|
|
10
|
-
"repository":
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/Koeroesi86/node-webserver.git",
|
|
13
|
+
"directory": "packages/node-lambda-invoke"
|
|
14
|
+
},
|
|
11
15
|
"publishConfig": {
|
|
12
16
|
"access": "public"
|
|
13
17
|
},
|
|
14
|
-
"scripts": {
|
|
15
|
-
"start": "nodemon example/example.js",
|
|
16
|
-
"generate-version": "node scripts/version.js",
|
|
17
|
-
"test": "echo \"Error: no test specified\" && exit 1"
|
|
18
|
-
},
|
|
19
18
|
"license": "MIT",
|
|
20
19
|
"dependencies": {
|
|
21
|
-
"dotenv": "^6.2.0",
|
|
22
20
|
"moment": "^2.24.0",
|
|
23
|
-
"nodemon": "^1.18.10",
|
|
24
21
|
"rimraf": "^2.6.3",
|
|
25
22
|
"uuid": "^3.3.2"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@types/node": "^24.0.0",
|
|
26
|
+
"@types/rimraf": "^2.0.5",
|
|
27
|
+
"@types/uuid": "^3.4.13",
|
|
28
|
+
"dotenv": "^6.2.0",
|
|
29
|
+
"nodemon": "^2.0.15",
|
|
30
|
+
"typescript": "^5.9.3"
|
|
31
|
+
},
|
|
32
|
+
"typings": "dist/index.d.ts",
|
|
33
|
+
"files": [
|
|
34
|
+
"dist",
|
|
35
|
+
"example",
|
|
36
|
+
".env.example",
|
|
37
|
+
"requests/.gitkeep",
|
|
38
|
+
"responses/.gitkeep"
|
|
39
|
+
],
|
|
40
|
+
"scripts": {
|
|
41
|
+
"build": "rimraf dist && tsc -p tsconfig.json",
|
|
42
|
+
"start": "nodemon --watch src --ext ts --exec \"npm run build --silent && node example/example.js\""
|
|
26
43
|
}
|
|
27
|
-
}
|
|
44
|
+
}
|
package/.travis.yml
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
language: node_js
|
|
2
|
-
node_js:
|
|
3
|
-
- "10"
|
|
4
|
-
cache:
|
|
5
|
-
yarn: true
|
|
6
|
-
directories:
|
|
7
|
-
- node_modules
|
|
8
|
-
script:
|
|
9
|
-
- export NODE_ENV=production
|
|
10
|
-
- export TRAVIS_TAG="$(git rev-parse --short ${TRAVIS_COMMIT})"
|
|
11
|
-
- yarn generate-version
|
|
12
|
-
deploy:
|
|
13
|
-
provider: npm
|
|
14
|
-
skip_cleanup: true
|
|
15
|
-
email: $NPM_EMAIL
|
|
16
|
-
api_key: $NPM_TOKEN
|