-
Notifications
You must be signed in to change notification settings - Fork 22
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: #1369 The Web Components Config API should store config by appId #1401
feat: #1369 The Web Components Config API should store config by appId #1401
Conversation
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.
Closing this pull request since the title does not match ^(:?[WIP] ?)?(?:build|ci|chore|docs|feat|fix|perf|refactor|revert|style|test):(?:\ +?#\d+?\ +?)?.* pattern. Please fix the title and re-open the pull request.
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.
Closing this pull request since the title does not match ^(:?[WIP] ?)?(?:build|ci|chore|docs|feat|fix|perf|refactor|revert|style|test):(?:\ +?#\d+?\ +?)?.* pattern. Please fix the title and re-open the pull request.
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.
Closing this pull request since the title does not match ^(:?[WIP] ?)?(?:build|ci|chore|docs|feat|fix|perf|refactor|revert|style|test):(?:\ +?#\d+?\ +?)?.* pattern. Please fix the title and re-open the pull request.
packages/web-components-config-server/src/routes/web-components-config/web-components-config.ts
Outdated
Show resolved
Hide resolved
export const webComponentsConfigPostHandler = async (req: AppRequest, res: AppResponse) => { | ||
try { | ||
const params = { | ||
data: { ...req.body, customerId: req.params.customerId, appId: req.params.appId }, |
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.
shoud we use opt chain to check null or undefined ?
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.
It's params from express route matching. Pretty sure about value of these field are always something not null
3f66d73
to
7735943
Compare
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.
LGTM
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.
Others LGTM
export const patchConfig = async ({ traceId, data }: UpdateParams): Promise<WebComponentConfig> => { | ||
try { | ||
logger.info('Updating config...', { traceId, data }) | ||
const { customerId, ...rest } = data | ||
const oldItem = await getConfigByClientId({ traceId, data: { customerId } }) | ||
logger.info('Patching config...', { traceId, data }) | ||
const { customerId, appId, ...rest } = data | ||
const oldItem = await getConfigByClientId({ traceId, data: { customerId, appId } }) | ||
const itemToUpdate = generateSchemaItem({ ...oldItem, ...rest }) | ||
const result = await dynamoDBMapper.update(itemToUpdate) | ||
logger.info('Patch config successfully', { traceId, result }) | ||
return result | ||
} catch (error) { | ||
await logger.error('Patch config failed', { traceId, error: stringifyError(error) }) | ||
throw error | ||
} | ||
} | ||
|
||
export const putConfig = async ({ traceId, data }): Promise<WebComponentConfig> => { | ||
try { | ||
logger.info('Updating config...', { traceId, data }) | ||
const itemToUpdate = generateSchemaItem(data) | ||
const result = await dynamoDBMapper.put(itemToUpdate) |
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.
just wonder why we need both PUT, and PATCH to update ?
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.
@phmngocnghia please fix to the next PR
Pull request checklist
Does this close any currently open issues?
fixes: #1369
Please check if your PR fulfills the following requirements:
yarn build
) was run locally and any changes were pushedyarn lint
) has passed locally and any fixes were made for failuresyarn test
) has passed locally and any fixes were made for failuresPull request type
Please check the type of change your PR introduces:
What is the current behavior?
old route:
webComponentsConfig.get('/:customerId', webComponentsConfigGetByIdHandler) webComponentsConfig.put('/', webComponentsConfigPutHandler) webComponentsConfig.patch('/:customerId', webComponentsConfigPatchHandler) webComponentsConfig.delete('/:customerId', webComponentsConfigDeleteHandler)
Issue Number: #1369
What is the new behavior?
Add
appId
to all CRUD routeswebComponentsConfig.post('/:customerId/:appId', webComponentsConfigPostHandler) webComponentsConfig.get('/:customerId/:appId', webComponentsConfigGetByIdHandler) webComponentsConfig.delete('/:customerId/:appId', webComponentsConfigDeleteHandler) webComponentsConfig.patch('/:customerId/:appId', webComponentsConfigPatchHandler) webComponentsConfig.put('/:customerId/:appId', webComponentsConfigPutHandler)
Does this introduce a breaking change?
Other information
Will need to add global secondary index key to
appId
field: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/getting-started-step-6.html