Skip to content
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

Refactor/netlify toml #357

Merged
merged 11 commits into from
Apr 6, 2022
Merged

Refactor/netlify toml #357

merged 11 commits into from
Apr 6, 2022

Conversation

alexanderleegs
Copy link
Contributor

@alexanderleegs alexanderleegs commented Feb 22, 2022

Overview

This PR introduces the refactor for the netlify toml retrieval flow. It introduces a newly created NetlifyTomlRouter and NetlifyTomlService.

Breaking Changes

  • No - this PR is backwards compatible

Features:

Sites router

  • GET /netlify-toml - retrieve the netlify-toml

Notes:
The NetlifyToml router no longer uses the site name of the repo (compared to the v1 endpoint), as we retrieve this from the isomer-build repo rather than the individual site, and we don't actually use the siteName anywhere.

Copy link
Contributor

@seaerchin seaerchin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems good generally but some comments and a general remark on the code structure

newroutes/__tests__/NetlifyToml.spec.js Outdated Show resolved Hide resolved
newroutes/netlifyToml.js Outdated Show resolved Hide resolved
const router = express.Router()

router.get(
"/netlify-toml",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should really maintain a mapping of keys to raw values

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you clarify which raw values you're referring to?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the /netlify-toml. idt it's a big issue cos the path should be used minimally? (lmk if i'm wrong)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, this is only used for this single endpoint - do you think router namespaces will help with this issue?

const netlifyTomlReadableContent = toml.parse(Base64.decode(content))

// Headers is an array of objects, specifying a set of access rules for each specified path
// Under our current assumption, we apply the first set of access rules to all paths
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think i might be lacking context - could i clarify what's the current assumption here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our assumption is that the file only contains a single set of access rules, so we take the first set!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we write that down in the comment too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, done in 6517e43

services/configServices/__tests__/NetlifyTomlService.js Outdated Show resolved Hide resolved
services/configServices/__tests__/NetlifyTomlService.js Outdated Show resolved Hide resolved
services/configServices/__tests__/NetlifyTomlService.js Outdated Show resolved Hide resolved
Base automatically changed from refactor/auth to develop March 14, 2022 03:56
@alexanderleegs alexanderleegs force-pushed the refactor/netlify-toml branch from a6cdec7 to 5517d45 Compare March 14, 2022 09:55
Copy link
Contributor

@seaerchin seaerchin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm; can be merged once the assumption is documented inside the comment!

const router = express.Router()

router.get(
"/netlify-toml",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the /netlify-toml. idt it's a big issue cos the path should be used minimally? (lmk if i'm wrong)

const netlifyTomlReadableContent = toml.parse(Base64.decode(content))

// Headers is an array of objects, specifying a set of access rules for each specified path
// Under our current assumption, we apply the first set of access rules to all paths
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we write that down in the comment too?

@alexanderleegs alexanderleegs force-pushed the refactor/netlify-toml branch from 6517e43 to a344e30 Compare April 4, 2022 07:32
@alexanderleegs alexanderleegs merged commit fbb38c8 into develop Apr 6, 2022
@mergify mergify bot deleted the refactor/netlify-toml branch April 6, 2022 01:34
harishv7 pushed a commit that referenced this pull request Feb 17, 2023
* Feat: add NetlifyTomlService

* Feat: add netlifyToml router

* Test: add new fixture for netlifyToml

* Test: add tests for netlifyToml service and router

* Fix: remove sitename from netlify-toml endpoint

* Nit: add line space

* Chore: include spec in name of test file and minor comment changes

* Rebase: use auth verify middleware in router

* Nit: add more details to comment

* Fix: move routers to appropriate subrouters and swap to res.locals

* Fix: axios mock in test for netlifytoml service
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants