Skip to content

Commit

Permalink
Merge branch 'next' into update-integration-router-plus-options-and-f…
Browse files Browse the repository at this point in the history
…ormatting
  • Loading branch information
seanspeaks committed Jan 24, 2025
2 parents 346188d + 5e5c0c9 commit 183e6a5
Show file tree
Hide file tree
Showing 38 changed files with 31,963 additions and 243 deletions.
30,650 changes: 30,650 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

40 changes: 28 additions & 12 deletions packages/core/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ const {
getArrayParamAndVerifyParamType,
getAndVerifyType,
} = require('./assertions/index');
const { Delegate, Worker, loadInstalledModules, createHandler } = require('./core/index');
const {
Delegate,
Worker,
loadInstalledModules,
createHandler,
} = require('./core/index');
const {
mongoose,
connectToDatabase,
Expand All @@ -17,7 +22,8 @@ const {
OrganizationUser,
State,
Token,
UserModel
UserModel,
WebsocketConnection,
} = require('./database/index');
const { Encrypt, Cryptor } = require('./encrypt/encrypt');
const {
Expand All @@ -26,7 +32,7 @@ const {
HaltError,
RequiredPropertyError,
ParameterTypeError,
} = require('./errors/index');
} = require('./errors/index');
const {
IntegrationBase,
IntegrationModel,
Expand All @@ -36,14 +42,10 @@ const {
IntegrationHelper,
createIntegrationRouter,
checkRequiredParams,
createFriggBackend
createFriggBackend,
} = require('./integrations/index');
const { TimeoutCatcher } = require('./lambda/index');
const {
debug,
initDebugLog,
flushDebugLog
} = require('./logs/index');
const { debug, initDebugLog, flushDebugLog } = require('./logs/index');
const {
Credential,
EntityManager,
Expand All @@ -55,11 +57,13 @@ const {
Requester,
ModuleConstants,
ModuleFactory,
Auther
Auther,
} = require('./module-plugin/index');

// const {Sync } = require('./syncs/model');

const { QueuerUtil } = require('./queues');

module.exports = {
// assertions
expectShallowEqualDbObject,
Expand All @@ -69,11 +73,13 @@ module.exports = {
getParamAndVerifyParamType,
getArrayParamAndVerifyParamType,
getAndVerifyType,

// core
Delegate,
Worker,
loadInstalledModules,
createHandler,

// database
mongoose,
connectToDatabase,
Expand All @@ -84,15 +90,19 @@ module.exports = {
State,
Token,
UserModel,
WebsocketConnection,

// encrypt
Encrypt,
Cryptor,

// errors
BaseError,
FetchError,
HaltError,
RequiredPropertyError,
ParameterTypeError,

// integrations
IntegrationBase,
IntegrationModel,
Expand All @@ -103,12 +113,15 @@ module.exports = {
checkRequiredParams,
createIntegrationRouter,
createFriggBackend,

// lambda
TimeoutCatcher,

// logs
debug,
initDebugLog,
flushDebugLog,

// module plugin
Credential,
EntityManager,
Expand All @@ -120,5 +133,8 @@ module.exports = {
Requester,
ModuleConstants,
ModuleFactory,
Auther
}
Auther,

// queues
QueuerUtil,
};
4 changes: 4 additions & 0 deletions packages/core/queues/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
const { QueuerUtil } = require('./queuer-util');
module.exports = {
QueuerUtil,
};
61 changes: 61 additions & 0 deletions packages/core/queues/queuer-util.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
const { v4: uuid } = require('uuid');
const AWS = require('aws-sdk');
const awsConfigOptions = () => {
const config = {};
if (process.env.IS_OFFLINE) {
console.log('Running in offline mode');
}
if (process.env.AWS_ENDPOINT) {
config.endpoint = process.env.AWS_ENDPOINT;
}
return config;
};
AWS.config.update(awsConfigOptions());
const sqs = new AWS.SQS();

const QueuerUtil = {
batchSend: async (entries = [], queueUrl) => {
console.log(
`Enqueuing ${entries.length} entries on SQS to queue ${queueUrl}`
);
const buffer = [];
const batchSize = 10;

for (const entry of entries) {
buffer.push({
Id: uuid(),
MessageBody: JSON.stringify(entry),
});
// Sends 10, then purges the buffer
if (buffer.length === batchSize) {
console.log('Buffer at 10, sending batch');
await sqs
.sendMessageBatch({
Entries: buffer,
QueueUrl: queueUrl,
})
.promise();
// Purge the buffer
buffer.splice(0, buffer.length);
}
}
console.log('Buffer at end, sending final batch');

// If any remaining entries under 10 are left in the buffer, send and return
if (buffer.length > 0) {
console.log(buffer);
return sqs
.sendMessageBatch({
Entries: buffer,
QueueUrl: queueUrl,
})
.promise();
}

// If we're exact... just return an empty object for now

return {};
},
};

module.exports = { QueuerUtil };
9 changes: 9 additions & 0 deletions packages/devtools/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
MIT License

Copyright (c) 2022 Left Hook Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
86 changes: 0 additions & 86 deletions packages/devtools/frigg-cli/environmentVariables.test.js

This file was deleted.

10 changes: 8 additions & 2 deletions packages/devtools/frigg-cli/index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
#!/usr/bin/env node

const { Command } = require('commander');
const { installCommand } = require('./installCommand');
const { installCommand } = require('./install-command');
const { startCommand } = require('./start-command'); // Assuming you have a startCommand module

const program = new Command();
program
.command('install [apiModuleName]')
.description('Install an API module')
.action(installCommand);

program
.command('start')
.description('Run the backend and optional frontend')
.action(startCommand);

program.parse(process.argv);

module.exports = { installCommand };
module.exports = { installCommand, startCommand };
Loading

0 comments on commit 183e6a5

Please sign in to comment.