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

Makes configuration uploadable thru API #240

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

jonathanbataire
Copy link

@jonathanbataire jonathanbataire commented Jan 14, 2025

Description

Current app requires rebuilding and re-deploying a app in order to change config
This approach introduces uploadable config making it easier to change configuration
The app defaults to the prebuilt config, once a new configuration is uploaded it overrides any pre-built config
Configuration can only be updated by CHT admins
Fixes #194

changes

  • introduces new api end point /api/config used with basic auth to upload config
curl -X POST https://user-management.com/api/config?domain=cht-instance.com \
     -u "username:password" \
     -H "Content-Type: application/json" \
     -d '{config}'

@jonathanbataire jonathanbataire marked this pull request as draft January 14, 2025 07:16
@jonathanbataire jonathanbataire marked this pull request as ready for review January 14, 2025 08:04
@@ -90,7 +93,7 @@ export class Config {
public static getParentProperty(contactType: ContactType): HierarchyConstraint {
const parentMatch = contactType.hierarchy.find(c => c.level === 1);
if (!parentMatch) {
throw new Error(`hierarchy at level 1 is required: "${contactType.name}"`);
throw new Error(`hierarchy at level 1 is required: "${contactType?.name}"`);
Copy link
Author

Choose a reason for hiding this comment

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

clean up

const contactMatch = config.contact_types.find(c => c.name === name);
public static async getContactType(name: string) : Promise<ContactType> {
const {config} = await init();
const contactMatch = config.contact_types.find(c => c?.name === name);
Copy link
Author

Choose a reason for hiding this comment

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

clean up

@jonathanbataire jonathanbataire changed the title Makes configuration uploadable thru UI Makes configuration uploadable thru API Feb 20, 2025
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.

separate config from main source code
1 participant