Skip to content

Instantly share code, notes, and snippets.

@mkotsollaris
Created November 27, 2022 21:08
Show Gist options
  • Save mkotsollaris/fb0a37193267f80a65a3b61bb04497ca to your computer and use it in GitHub Desktop.
Save mkotsollaris/fb0a37193267f80a65a3b61bb04497ca to your computer and use it in GitHub Desktop.
Drift engine with Upstash pseudo-code
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