Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 36 additions & 36 deletions npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
],
"license": "MIT",
"dependencies": {
"axios": "^1.9.0",
"axios": "^1.10.0",
"bcryptjs": "^3.0.2",
"cors": "^2.8.5",
"express": "^5.1.0",
Expand All @@ -50,7 +50,7 @@
"jsonwebtoken": "^9.0.2",
"moment": "^2.30.1",
"mongodb": "^6.17.0",
"mongoose": "^8.15.1",
"mongoose": "^8.15.2",
"pino": "^9.7.0",
"pino-pretty": "^13.0.0",
"swagger-ui-express": "^5.0.1",
Expand All @@ -59,12 +59,12 @@
},
"devDependencies": {
"env-cmd": "^10.1.0",
"eslint": "^9.28.0",
"eslint": "^9.29.0",
"jest": "^30.0.0",
"jest-sonar-reporter": "^2.0.0",
"node-notifier": "^10.0.1",
"nodemon": "^3.1.10",
"sinon": "^20.0.0",
"sinon": "^21.0.0",
"supertest": "^7.1.1"
},
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion requests/Switcher Resolver Node.postman_collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@
"body": {
"mode": "graphql",
"graphql": {
"query": "query Domain(\r\n $name: String, \r\n $environment: String, \r\n $_component: String) {\r\n domain(\r\n name: $name, \r\n environment: $environment,\r\n _component: $_component\r\n ) {\r\n name\r\n version\r\n description\r\n activated\r\n group {\r\n name\r\n description\r\n activated\r\n config {\r\n key\r\n description\r\n activated\r\n strategies {\r\n strategy\r\n activated\r\n operation\r\n values\r\n }\r\n relay {\r\n type\r\n method\r\n authPrefix\r\n verifiedByEnv { env value }\r\n authTokenByEnv { env value }\r\n statusByEnv { env value }\r\n endpointByEnv { env value }\r\n }\r\n components\r\n }\r\n }\r\n }\r\n}",
"query": "query Domain(\r\n $name: String, \r\n $environment: String, \r\n $_component: String) {\r\n domain(\r\n name: $name, \r\n environment: $environment,\r\n _component: $_component\r\n ) {\r\n name\r\n version\r\n description\r\n activated\r\n group {\r\n name\r\n description\r\n activated\r\n config {\r\n key\r\n description\r\n activated\r\n strategies {\r\n strategy\r\n activated\r\n operation\r\n values\r\n }\r\n relay {\r\n type\r\n method\r\n activated\r\n authPrefix\r\n verifiedByEnv { env value }\r\n authTokenByEnv { env value }\r\n statusByEnv { env value }\r\n endpointByEnv { env value }\r\n }\r\n components\r\n }\r\n }\r\n }\r\n}",
"variables": "{\r\n \"name\": \"{{domain_name}}\",\r\n \"environment\": \"{{env_name}}\",\r\n \"_component\": \"{{component_name}}\"\r\n}"
}
},
Expand Down
22 changes: 14 additions & 8 deletions src/client/configuration-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,28 +76,34 @@ export const relayType = new GraphQLObjectType({
method: {
type: GraphQLString,
},
activated: {
type: GraphQLBoolean,
resolve: (source, _args, { environment }) => {
return source.activated[`${environment}`];
}
},
verifiedByEnv: {
type: new GraphQLList(envValue),
resolve: (source, _args, context) => {
return resolveEnvValue(source, 'verified', Object.keys(source.verified), context.environment);
resolve: (source) => {
return resolveEnvValue(source, 'verified', Object.keys(source.verified));
}
},
endpointByEnv: {
type: new GraphQLList(envValue),
resolve: (source, _args, context) => {
return resolveEnvValue(source, 'endpoint', Object.keys(source.endpoint), context.environment);
resolve: (source) => {
return resolveEnvValue(source, 'endpoint', Object.keys(source.endpoint));
}
},
statusByEnv: {
type: new GraphQLList(envStatus),
resolve: (source, _args, context) => {
return resolveEnvValue(source, 'activated', Object.keys(source.activated), context.environment);
resolve: (source) => {
return resolveEnvValue(source, 'activated', Object.keys(source.activated));
}
},
authTokenByEnv: {
type: new GraphQLList(envValue),
resolve: (source, _args, context) => {
return resolveEnvValue(source, 'auth_token', Object.keys(source.auth_token), context.environment);
resolve: (source) => {
return resolveEnvValue(source, 'auth_token', Object.keys(source.auth_token));
}
},
authPrefix: {
Expand Down
6 changes: 1 addition & 5 deletions src/client/resolvers.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { isRelayVerified, isRelayValid } from '../services/config.js';

export const resolveConfigByKey = async (domain, key) => Config.findOne({ domain, key }, null, { lean: true });

export function resolveEnvValue(source, field, keys, environment) {
export function resolveEnvValue(source, field, keys) {
const arrValue = [];

keys.forEach(k => {
Expand All @@ -21,10 +21,6 @@ export function resolveEnvValue(source, field, keys, environment) {
});
});

if (environment) {
return arrValue.filter(e => e.env === environment);
}

return arrValue;
}

Expand Down
40 changes: 8 additions & 32 deletions src/helpers/cache/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,51 +2,27 @@ export const domainQuery = (id) => `
query {
domain(_id: "${id}") {
version
statusByEnv {
env
value
}
statusByEnv { env value }
group {
statusByEnv {
env
value
}
statusByEnv { env value }
config {
key
components
statusByEnv {
env
value
}
statusByEnv { env value }
strategies {
strategy
operation
values
statusByEnv {
env
value
}
statusByEnv { env value }
}
relay {
type
method
authPrefix
authTokenByEnv {
env
value
}
endpointByEnv {
env
value
}
statusByEnv {
env
value
}
verifiedByEnv {
env
value
}
authTokenByEnv { env value }
endpointByEnv { env value }
statusByEnv { env value }
verifiedByEnv { env value }
}
}
}
Expand Down
17 changes: 5 additions & 12 deletions tests/graphql-utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,10 @@ export const domainQuery = (where, group, config, strategy) => {
relay {
type
method
endpointByEnv {
env
value
}
statusByEnv {
env
value
}
statusByEnv {
env
value
}
activated
endpointByEnv { env value }
statusByEnv { env value }
statusByEnv { env value }
}
components
}
Expand Down Expand Up @@ -175,6 +167,7 @@ export const expected102 = `
"relay": {
"type": "NOTIFICATION",
"method": "POST",
"activated": false,
"endpointByEnv": [{
"env": "default",
"value": "http://localhost:3000"
Expand Down