You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import {PUBLIC_ENV} from '$env/static/public'
import authAPI, {fake as authFake} from "$lib/authAPI";
import type {AuthAPI} from "$lib/authAPI";
...
interface APIs {
authAPI: AuthAPI,
...
}
const env = PUBLIC_ENV
function init(): APIs {
if (env === "local") {
return {
authAPI: authFake(),
...
}
} else {
return {
authAPI: authAPI("some host"),
...
}
}
}
export default init()
It works fine as it is, but I'm a bit concerned about the way my code is exposed. Ideally I would like to remove extra code from the files a user can see. So the user won't load my "fake" implementation since it also has quite a lot of sample data I use for testing.
So the question is - can I do something about this extra code so it's removed on the build stage this way:
from if (env === "local") { ... } else { ... } to { authAPI: authFake() } or { authAPI: authAPI("some host") }
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi, I have a following code in $lib:
It works fine as it is, but I'm a bit concerned about the way my code is exposed. Ideally I would like to remove extra code from the files a user can see. So the user won't load my "fake" implementation since it also has quite a lot of sample data I use for testing.
So the question is - can I do something about this extra code so it's removed on the build stage this way:
if (env === "local") { ... } else { ... }
to{ authAPI: authFake() }
or{ authAPI: authAPI("some host") }
or am I just worrying to much about it?
Beta Was this translation helpful? Give feedback.
All reactions