<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Shared Script]]></title><description><![CDATA[<p>I currently have the following same config at the top of every one of my scripts:</p>
<pre><code class="language-js">const config = {
    &quot;user&quot;: &quot;username&quot;,
    &quot;password&quot;: &quot;password&quot;,
    &quot;server&quot;: &quot;localhost&quot;,
    &quot;database&quot;: &quot;DatabaseName&quot;,
    &quot;options&quot;: {
        &quot;encrypt&quot;: true
    }
};
</code></pre>
<p>The location of my database and username and password has changed a bunch of times and it's a real pain to go into every script file to update this. Is there a better place I can put this so all the scripts have access to config and I only need to update one file?</p>
]]></description><link>https://forum.jsreport.net/topic/1795/shared-script</link><generator>RSS for Node</generator><lastBuildDate>Sun, 15 Nov 2026 03:22:50 GMT</lastBuildDate><atom:link href="https://forum.jsreport.net/topic/1795.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 02 Nov 2020 20:05:59 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Shared Script on Invalid Date]]></title><description><![CDATA[<p>I currently have the following same config at the top of every one of my scripts:</p>
<pre><code class="language-js">const config = {
    &quot;user&quot;: &quot;username&quot;,
    &quot;password&quot;: &quot;password&quot;,
    &quot;server&quot;: &quot;localhost&quot;,
    &quot;database&quot;: &quot;DatabaseName&quot;,
    &quot;options&quot;: {
        &quot;encrypt&quot;: true
    }
};
</code></pre>
<p>The location of my database and username and password has changed a bunch of times and it's a real pain to go into every script file to update this. Is there a better place I can put this so all the scripts have access to config and I only need to update one file?</p>
]]></description><link>https://forum.jsreport.net/post/8005</link><guid isPermaLink="true">https://forum.jsreport.net/post/8005</guid><dc:creator><![CDATA[chriscrowley]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Shared Script on Invalid Date]]></title><description><![CDATA[<p>One option is to use environment variables to reach connection strings<br />
<a href="https://jsreport.net/learn/scripts#environment-variables-and-configuration" rel="nofollow">https://jsreport.net/learn/scripts#environment-variables-and-configuration</a></p>
<p>Another option is to create one script and mark it as global.<br />
It will run every time and you can set the connection string to <code>req.options.connectionString</code> for example and reach it there in your other scripts.<br />
<a href="https://jsreport.net/learn/scripts#global-scripts" rel="nofollow">https://jsreport.net/learn/scripts#global-scripts</a></p>
<p>The third option is to use assets, store there a json with a connection string, and embed it to every script.<br />
<code>let connectionString = &quot;{#asset connectionString.json @encoding=string}&quot;</code><br />
<a href="https://jsreport.net/learn/assets" rel="nofollow">https://jsreport.net/learn/assets</a></p>
]]></description><link>https://forum.jsreport.net/post/8007</link><guid isPermaLink="true">https://forum.jsreport.net/post/8007</guid><dc:creator><![CDATA[jan_blaha]]></dc:creator><pubDate>Invalid Date</pubDate></item></channel></rss>