Skip to content
This repository has been archived by the owner on May 23, 2024. It is now read-only.

Add ability to programmatically override environment defaults #51

Open
tbakerx opened this issue Jul 13, 2022 · 1 comment
Open

Add ability to programmatically override environment defaults #51

tbakerx opened this issue Jul 13, 2022 · 1 comment

Comments

@tbakerx
Copy link
Contributor

tbakerx commented Jul 13, 2022

Currently we can override environment defaults by setting the relevant environment variables, but it would be nice to programmatically set our own defaults

@jasonscharf
Copy link
Contributor

Hi Tim,

These are the from the Next.js integration guide (with a modified Redis host) and work:

const redis = getRedisBackend({
    host: "foo",
});
const json = getJsonSiteBackend();

const defaultOptions: Partial<InstantBanditServerOptions> = {
    sessions: redis,
    metrics: redis,
    models: json,
};
export const server = getBanditServer(defaultOptions);

The order is code -> environment (if present) -> defaults from code (set in environment.ts as fallbacks).

Let me know if I'm missing something. I think moving the example and the precedence to the readme would clarify things, what do you think?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants