@friggframework/core 2.0.0--canary.396.b9f7d5a.0 → 2.0.0--canary.396.607ab7a.0
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/handlers/app-definition-loader.js +38 -0
- package/handlers/backend-utils.js +0 -36
- package/handlers/routers/auth.js +1 -1
- package/handlers/routers/integration-defined-routers.js +1 -1
- package/handlers/routers/user.js +1 -1
- package/handlers/workers/integration-defined-workers.js +1 -1
- package/integrations/integration-router.js +3 -1
- package/package.json +5 -5
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
const { findNearestBackendPackageJson } = require('@friggframework/core/utils');
|
|
2
|
+
const path = require('node:path');
|
|
3
|
+
const fs = require('fs-extra');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Loads the App definition from the nearest backend package
|
|
7
|
+
* @function loadAppDefinition
|
|
8
|
+
* @description Searches for the nearest backend package.json, loads the corresponding index.js file,
|
|
9
|
+
* and extracts the application definition containing integrations and user configuration.
|
|
10
|
+
* @returns {{integrations: Array<object>, userConfig: object | null}} An object containing the application definition.
|
|
11
|
+
* @throws {Error} Throws error if backend package.json cannot be found.
|
|
12
|
+
* @throws {Error} Throws error if index.js file cannot be found in the backend directory.
|
|
13
|
+
* @example
|
|
14
|
+
* const { integrations, userConfig } = loadAppDefinition();
|
|
15
|
+
* console.log(`Found ${integrations.length} integrations`);
|
|
16
|
+
*/
|
|
17
|
+
function loadAppDefinition() {
|
|
18
|
+
const backendPath = findNearestBackendPackageJson();
|
|
19
|
+
if (!backendPath) {
|
|
20
|
+
throw new Error('Could not find backend package.json');
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const backendDir = path.dirname(backendPath);
|
|
24
|
+
const backendFilePath = path.join(backendDir, 'index.js');
|
|
25
|
+
if (!fs.existsSync(backendFilePath)) {
|
|
26
|
+
throw new Error('Could not find index.js');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const backendJsFile = require(backendFilePath);
|
|
30
|
+
const appDefinition = backendJsFile.Definition;
|
|
31
|
+
|
|
32
|
+
const { integrations = [], user: userConfig = null } = appDefinition;
|
|
33
|
+
return { integrations, userConfig };
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
module.exports = {
|
|
37
|
+
loadAppDefinition,
|
|
38
|
+
};
|
|
@@ -1,41 +1,6 @@
|
|
|
1
|
-
const { findNearestBackendPackageJson } = require('@friggframework/core/utils');
|
|
2
|
-
const path = require('node:path');
|
|
3
|
-
const fs = require('fs-extra');
|
|
4
1
|
const { Router } = require('express');
|
|
5
2
|
const { Worker } = require('@friggframework/core');
|
|
6
3
|
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Loads the App definition from the nearest backend package
|
|
10
|
-
* @function loadAppDefinition
|
|
11
|
-
* @description Searches for the nearest backend package.json, loads the corresponding index.js file,
|
|
12
|
-
* and extracts the application definition containing integrations and user configuration.
|
|
13
|
-
* @returns {{integrations: Array<object>, userConfig: object | null}} An object containing the application definition.
|
|
14
|
-
* @throws {Error} Throws error if backend package.json cannot be found.
|
|
15
|
-
* @throws {Error} Throws error if index.js file cannot be found in the backend directory.
|
|
16
|
-
* @example
|
|
17
|
-
* const { integrations, userConfig } = loadAppDefinition();
|
|
18
|
-
* console.log(`Found ${integrations.length} integrations`);
|
|
19
|
-
*/
|
|
20
|
-
function loadAppDefinition() {
|
|
21
|
-
const backendPath = findNearestBackendPackageJson();
|
|
22
|
-
if (!backendPath) {
|
|
23
|
-
throw new Error('Could not find backend package.json');
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const backendDir = path.dirname(backendPath);
|
|
27
|
-
const backendFilePath = path.join(backendDir, 'index.js');
|
|
28
|
-
if (!fs.existsSync(backendFilePath)) {
|
|
29
|
-
throw new Error('Could not find index.js');
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const backendJsFile = require(backendFilePath);
|
|
33
|
-
const appDefinition = backendJsFile.Definition;
|
|
34
|
-
|
|
35
|
-
const { integrations = [], user: userConfig = null } = appDefinition;
|
|
36
|
-
return { integrations, userConfig };
|
|
37
|
-
}
|
|
38
|
-
|
|
39
4
|
const loadRouterFromObject = (IntegrationClass, routerObject) => {
|
|
40
5
|
const router = Router();
|
|
41
6
|
const { path, method, event } = routerObject;
|
|
@@ -100,5 +65,4 @@ const createQueueWorker = (integrationClass, integrationFactory) => {
|
|
|
100
65
|
module.exports = {
|
|
101
66
|
loadRouterFromObject,
|
|
102
67
|
createQueueWorker,
|
|
103
|
-
loadAppDefinition,
|
|
104
68
|
};
|
package/handlers/routers/auth.js
CHANGED
|
@@ -2,7 +2,7 @@ const { createIntegrationRouter } = require('@friggframework/core');
|
|
|
2
2
|
const { createAppHandler } = require('./../app-handler-helpers');
|
|
3
3
|
const {
|
|
4
4
|
loadAppDefinition,
|
|
5
|
-
} = require('
|
|
5
|
+
} = require('../app-definition-loader');
|
|
6
6
|
const { UserRepository } = require('../../user/user-repository');
|
|
7
7
|
const { IntegrationFactory } = require('../../integrations/integration-factory');
|
|
8
8
|
const { GetUserFromBearerToken } = require('../../user/use-cases/get-user-from-bearer-token');
|
|
@@ -2,7 +2,7 @@ const { createAppHandler } = require('./../app-handler-helpers');
|
|
|
2
2
|
const {
|
|
3
3
|
loadAppDefinition,
|
|
4
4
|
loadRouterFromObject,
|
|
5
|
-
} = require('
|
|
5
|
+
} = require('../app-definition-loader');
|
|
6
6
|
const { Router } = require('express');
|
|
7
7
|
const { IntegrationFactory } = require('../../integrations/integration-factory');
|
|
8
8
|
|
package/handlers/routers/user.js
CHANGED
|
@@ -10,7 +10,7 @@ const {
|
|
|
10
10
|
CreateTokenForUserId,
|
|
11
11
|
} = require('../../user/use-cases/create-token-for-user-id');
|
|
12
12
|
const catchAsyncError = require('express-async-handler');
|
|
13
|
-
const { loadAppDefinition } = require('../
|
|
13
|
+
const { loadAppDefinition } = require('../app-definition-loader');
|
|
14
14
|
|
|
15
15
|
const router = express();
|
|
16
16
|
const { userConfig } = loadAppDefinition();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const { createHandler } = require('@friggframework/core');
|
|
2
|
-
const { loadAppDefinition, createQueueWorker } = require('../
|
|
2
|
+
const { loadAppDefinition, createQueueWorker } = require('../app-definition-loader');
|
|
3
3
|
const { IntegrationFactory } = require('../../integrations/integration-factory');
|
|
4
4
|
|
|
5
5
|
const handlers = {};
|
|
@@ -12,7 +12,9 @@ const { GetCredentialForUser } = require('../credential/use-cases/get-credential
|
|
|
12
12
|
const { CreateIntegration } = require('./use-cases/create-integration');
|
|
13
13
|
const { ModuleService } = require('../module-plugin/module-service');
|
|
14
14
|
const { ModuleRepository } = require('../module-plugin/module-repository');
|
|
15
|
-
const {
|
|
15
|
+
const {
|
|
16
|
+
loadAppDefinition,
|
|
17
|
+
} = require('../handlers/app-definition-loader');
|
|
16
18
|
|
|
17
19
|
|
|
18
20
|
const { integrations } = loadAppDefinition();
|
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--canary.396.
|
|
4
|
+
"version": "2.0.0--canary.396.607ab7a.0",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@hapi/boom": "^10.0.1",
|
|
7
7
|
"aws-sdk": "^2.1200.0",
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
"uuid": "^9.0.1"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@friggframework/eslint-config": "2.0.0--canary.396.
|
|
26
|
-
"@friggframework/prettier-config": "2.0.0--canary.396.
|
|
27
|
-
"@friggframework/test": "2.0.0--canary.396.
|
|
25
|
+
"@friggframework/eslint-config": "2.0.0--canary.396.607ab7a.0",
|
|
26
|
+
"@friggframework/prettier-config": "2.0.0--canary.396.607ab7a.0",
|
|
27
|
+
"@friggframework/test": "2.0.0--canary.396.607ab7a.0",
|
|
28
28
|
"@types/lodash": "4.17.15",
|
|
29
29
|
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
30
30
|
"chai": "^4.3.6",
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
},
|
|
54
54
|
"homepage": "https://github.com/friggframework/frigg#readme",
|
|
55
55
|
"description": "",
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "607ab7a7440562858c6d7440b8983a00931be283"
|
|
57
57
|
}
|