がんばって実装する。
YOUR_PRJECT_NAME
とYOUR_ACCESS_TOKEN
は書き換えてくだあい
import { serve } from "https://deno.land/std@0.177.0/http/server.ts";
Deno.env.bulkSet = async obj => fetch(`https://dash.deno.com/_api/projects/YOUR_PRJECT_NAME/env`, {
method: 'PATCH',
headers: {
'Content-Type': 'application/json',
'cookie': 'token=YOUR_ACCESS_TOKEN'
},
body: JSON.stringify(obj)
})
Deno.env.set = async (key, value) => Deno.env.bulkSet({[key]: value})
Deno.env.delete = async key => Deno.env.bulkSet({[key]: null})
Deno.env.bulkDelete = async keys => Deno.env.bulkSet(Object.fromEntries(keys.map(key => [key, null])))
serve(async (req: Request) => {
await Deno.env.set('SOME_VAR', 'Value')
await Deno.env.delete('SOME_VAR')
await Deno.env.bulkSet({ lastName: "John", firstName: "Doe" })
await Deno.env.bulkDelete(['a', 'b'])
return new Response("Hello World")
});