Quantcast
Channel: Active questions tagged config - Stack Overflow
Viewing all articles
Browse latest Browse all 5060

How do I create global server config objects in sveltekit?

$
0
0

In my sveltekit app, I keep doing this in my +server.js files throughout my routes:

import config from '$lib/server/config.js';

where the exported config object contains database connection details, etc. (some of which in turn come from environment variables), and this information is adapted to the environment I am running in (dev, prod, etc.).

I have two questions about this. First, is there a canonical place to put such a config.js file other than where I am putting it?

Second, is there a way to load this config object globally so I don't need to load it repeatedly in every +server.js file that needs this information? I could put it all in environment variables (via .env, for example), but then I lose some of the conveniences of my config.js.


Viewing all articles
Browse latest Browse all 5060

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>