@friggframework/core 2.0.0-next.0 → 2.0.0-next.10
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/database/index.js +10 -8
- package/database/models/WebsocketConnection.js +49 -0
- package/handlers/app-handler-helpers.js +57 -0
- package/handlers/backend-utils.js +87 -0
- package/handlers/routers/auth.js +26 -0
- package/handlers/routers/integration-defined-routers.js +42 -0
- package/handlers/routers/middleware/loadUser.js +15 -0
- package/handlers/routers/middleware/requireLoggedInUser.js +12 -0
- package/handlers/routers/user.js +41 -0
- package/handlers/routers/websocket.js +55 -0
- package/handlers/workers/integration-defined-workers.js +24 -0
- package/index.js +28 -12
- package/integrations/integration-base.js +135 -48
- package/integrations/integration-factory.js +151 -54
- package/integrations/integration-model.js +4 -0
- package/integrations/integration-router.js +120 -96
- package/integrations/options.js +2 -3
- package/module-plugin/auther.js +97 -54
- package/package.json +5 -5
- package/queues/index.js +4 -0
- package/queues/queuer-util.js +61 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@friggframework/core",
|
|
3
3
|
"prettier": "@friggframework/prettier-config",
|
|
4
|
-
"version": "2.0.0-next.
|
|
4
|
+
"version": "2.0.0-next.10",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@hapi/boom": "^10.0.1",
|
|
7
7
|
"aws-sdk": "^2.1200.0",
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
"node-fetch": "^2.6.7"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
|
-
"@friggframework/eslint-config": "
|
|
19
|
-
"@friggframework/prettier-config": "
|
|
20
|
-
"@friggframework/test": "
|
|
18
|
+
"@friggframework/eslint-config": "2.0.0-next.10",
|
|
19
|
+
"@friggframework/prettier-config": "2.0.0-next.10",
|
|
20
|
+
"@friggframework/test": "2.0.0-next.10",
|
|
21
21
|
"@types/lodash": "^4.14.191",
|
|
22
22
|
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
23
23
|
"chai": "^4.3.6",
|
|
@@ -48,5 +48,5 @@
|
|
|
48
48
|
},
|
|
49
49
|
"homepage": "https://github.com/friggframework/frigg#readme",
|
|
50
50
|
"description": "",
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "67dc76e94c02c0074f7ff2d7292c4d2203bf3949"
|
|
52
52
|
}
|
package/queues/index.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
const { v4: uuid } = require('uuid');
|
|
2
|
+
const AWS = require('aws-sdk');
|
|
3
|
+
const awsConfigOptions = () => {
|
|
4
|
+
const config = {};
|
|
5
|
+
if (process.env.IS_OFFLINE) {
|
|
6
|
+
console.log('Running in offline mode');
|
|
7
|
+
}
|
|
8
|
+
if (process.env.AWS_ENDPOINT) {
|
|
9
|
+
config.endpoint = process.env.AWS_ENDPOINT;
|
|
10
|
+
}
|
|
11
|
+
return config;
|
|
12
|
+
};
|
|
13
|
+
AWS.config.update(awsConfigOptions());
|
|
14
|
+
const sqs = new AWS.SQS();
|
|
15
|
+
|
|
16
|
+
const QueuerUtil = {
|
|
17
|
+
batchSend: async (entries = [], queueUrl) => {
|
|
18
|
+
console.log(
|
|
19
|
+
`Enqueuing ${entries.length} entries on SQS to queue ${queueUrl}`
|
|
20
|
+
);
|
|
21
|
+
const buffer = [];
|
|
22
|
+
const batchSize = 10;
|
|
23
|
+
|
|
24
|
+
for (const entry of entries) {
|
|
25
|
+
buffer.push({
|
|
26
|
+
Id: uuid(),
|
|
27
|
+
MessageBody: JSON.stringify(entry),
|
|
28
|
+
});
|
|
29
|
+
// Sends 10, then purges the buffer
|
|
30
|
+
if (buffer.length === batchSize) {
|
|
31
|
+
console.log('Buffer at 10, sending batch');
|
|
32
|
+
await sqs
|
|
33
|
+
.sendMessageBatch({
|
|
34
|
+
Entries: buffer,
|
|
35
|
+
QueueUrl: queueUrl,
|
|
36
|
+
})
|
|
37
|
+
.promise();
|
|
38
|
+
// Purge the buffer
|
|
39
|
+
buffer.splice(0, buffer.length);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
console.log('Buffer at end, sending final batch');
|
|
43
|
+
|
|
44
|
+
// If any remaining entries under 10 are left in the buffer, send and return
|
|
45
|
+
if (buffer.length > 0) {
|
|
46
|
+
console.log(buffer);
|
|
47
|
+
return sqs
|
|
48
|
+
.sendMessageBatch({
|
|
49
|
+
Entries: buffer,
|
|
50
|
+
QueueUrl: queueUrl,
|
|
51
|
+
})
|
|
52
|
+
.promise();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// If we're exact... just return an empty object for now
|
|
56
|
+
|
|
57
|
+
return {};
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
module.exports = { QueuerUtil };
|