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(server): YAML config file support #7894
Conversation
@@ -341,19 +342,19 @@ export class SystemConfigCore { | |||
if (force || !this.configCache) { | |||
try { | |||
const file = await this.repository.readFile(filepath); | |||
const json = JSON.parse(file.toString()); | |||
const config = loadYaml(file.toString()) as any; |
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.
js-yaml has this option:
json
(default: false) - compatibility with JSON.parse behaviour. If true, then duplicate keys in a mapping will override values rather than throwing an error.
I don't think we need it, right?
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.
Yeah, that probably doesn't matter. I don't think it matters how exactly the parser works, just that it will still have to pass validation with class-transformer/class-validator either way. This seems like a more edge-case for parsing that we don't care about. Although, it would be great to add an e2e test for this too. I can probably do that if you don't want to both with it.
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.
Oh I didn't realize you could unit test it so easily, but that works too.
if (!_.isEmpty(json)) { | ||
this.logger.warn(`Unknown keys found: ${JSON.stringify(json, null, 2)}`); | ||
if (!_.isEmpty(config)) { | ||
this.logger.warn(`Unknown keys found: ${JSON.stringify(config, null, 2)}`); |
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 left this as just JSON output rather than trying to format based on what the input was, to keep the code simple.
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 think that's fine, it is just a warning anyways and the user should be able to map it back themselves.
Deploying with Cloudflare Pages
|
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.
Noice.
No description provided.