-
Notifications
You must be signed in to change notification settings - Fork 46
feat: supports a few domains #278
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: supports a few domains #278
Conversation
ilc/server/registry/Registry.js
Outdated
* Returns new object with routes list for current domain | ||
* and without "supportedDomains" data and property "domainId" inside every "route" | ||
*/ | ||
#filterConfigByDomain = (config, domain) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we avoid fn params modification & rather create new object?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I decided to use deepmerge
as a clone-tool. What do you think about it?
https://github.com/namecheap/ilc/pull/278/files#diff-fe500a7438ccd9d0cbb535ee88ca3a0ba5f994e030980275f9821b4e96d0312dR25
ilc/server/registry/Registry.js
Outdated
|
||
const { domain } = options?.filter || {}; | ||
if (domain) { | ||
res.data = this.#filterConfigByDomain(res.data, domain); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pass options?.filter
directly to this.#filterConfigByDomain
& rename it to this.#filterConfig
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Pls set merge into |
ilc/server/registry/Registry.js
Outdated
@@ -50,13 +50,18 @@ module.exports = class Registry { | |||
this.#logger.info('Registry preheated successfully!'); | |||
} | |||
|
|||
#getConfig = async () => { | |||
#getConfig = async (options) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pls use memoization before filtration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
registry/server/routes/config.ts
Outdated
@@ -90,6 +91,25 @@ router.get('/', async (req, res) => { | |||
return acc; | |||
}, {}); | |||
|
|||
data.supportedDomains = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
data.supportedDomains = [ | |
data.routerDomains = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -19,7 +21,12 @@ function makeAppId(appName, slotName) { | |||
return `${appName.replace('@portal/', '')}__at__${slotName}`; | |||
} | |||
|
|||
function clone(source) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
function clone(source) { | |
function cloneObjectDeep(source) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this method respect not only objects, so I will rename it to cloneDeep
https://github.com/namecheap/ilc/pull/280/files#diff-fe500a7438ccd9d0cbb535ee88ca3a0ba5f994e030980275f9821b4e96d0312dR24
const clonedConfig = clone(config); | ||
const { domain } = filter; | ||
|
||
if (domain) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pls inverse condition here to decrease nesting level.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did it consciously since property filter
can contain other filters in the future
No description provided.