Last active
September 1, 2022 13:21
-
-
Save dougwithseismic/b8c03ddc6b80b49abc4675048a2f6d2e to your computer and use it in GitHub Desktop.
JavaScript Express / Node : How can I serve different scripts to different customers like Hotjar does?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script defer src='https://my.backend.io/v1/library/customer-xyz123/ /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.get('/v1/library/:uid', async (req, res) => { | |
const customerId = req.params.uid | |
const settings = await getSettings(customerId) // { name : 'doug', features: [1, 2 ,5] ... } | |
res.sendFile('./libary.js') // How can I take ./library.js as a template, and add customer-xyz123's settings to the script? | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const settings = { name : 'doug', features: [1, 2 ,5] ... } | |
doStuff(settings) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment