1
0
Fork 0
mirror of synced 2024-10-02 18:16:29 +13:00

update process.env with new value

This commit is contained in:
kevmodrome 2020-07-02 21:01:34 +02:00
parent e3e5caaf97
commit 160c3ef7c4

View file

@ -20,7 +20,13 @@ exports.fetch = async function (ctx) {
}
exports.update = async function (ctx) {
// Do something with ctx.request.body: <{ value: value }>
// Set process.env
const envKeyName = `${ctx.params.key.toUpperCase()}_API_KEY`
process.env[envKeyName] = ctx.request.body.value
// Write to file
// TODO
ctx.status = 200
ctx.message = `Updated ${ctx.params.key} API key succesfully.`
ctx.body = { [ctx.params.key]: ctx.request.body.value }
@ -33,7 +39,8 @@ async function getEnvironmentVariables() {
return data = fs.readFileSync(filePath, 'utf8');
}
async function extractKeys() {
async function extractKeys(content) {
const lines = content.split(/\r?\n/)
// Extract keys here
return []
}