/drift-engine.ts Secret
Created
November 27, 2022 21:08
Drift engine with Upstash pseudo-code
This file contains 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 getAllRemoteState = async () => { | |
const result = await getAllRemoteKeys(); | |
const enabledResources: string[] = await result.reduce( async (acc:string[], currKey:string) => { | |
const accum = await acc; | |
await axios.get(`${URL}/get/${currKey}`, getHeaders()).then(({data}) => data); | |
accum.push(currKey); | |
return accum; | |
}, []); | |
return enabledResources; | |
} | |
const computeToBeDeleted= async (directoryPath='') => { | |
const localResources = await getLocalResources(directoryPath); | |
const remoteResources = await getAllRemoteResourceKeys(); | |
const result = remoteResources.filter(x => !localResources.includes(x)); | |
return result; | |
} | |
const computeToBeAdded = async (directoryPath='') => { | |
const localTurboFlags = await getTurboFlagsOnDirectory(directoryPath); | |
const remoteTurboFlags = await getAllRemoteState(); | |
const result = localTurboFlags.filter(x => !remoteTurboFlags.includes(x)) | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment