A basic template for limiting how often code is triggered, ideal for commands to prevent spam. Use this with any endpoint!
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
let key = await lib.utils.kv['@release'].get({
key: process.env.key_name,
});
if (key) return console.log('Key exists, so the code was not run!');
await lib.utils.kv['@release'].set({
key: process.env.key_name, // Set this in environment variables
value: `true`,
ttl: 20, // Set seconds timeout here. The key self-destructs when the time is up
});
// Execute cool code down here