adds getEnvironmentVariables function
This commit is contained in:
parent
f6f2dfb8e4
commit
7a7ad75e12
|
@ -1,13 +1,15 @@
|
||||||
const CouchDB = require("../../db")
|
const fs = require("fs")
|
||||||
const clientDb = require("../../db/clientDb")
|
|
||||||
const bcrypt = require("../../utilities/bcrypt")
|
const ENV_FILE_PATH = ".budibase/.env"
|
||||||
const getUserId = userName => `user_${userName}`
|
|
||||||
const {
|
|
||||||
POWERUSER_LEVEL_ID,
|
|
||||||
ADMIN_LEVEL_ID,
|
|
||||||
} = require("../../utilities/accessLevels")
|
|
||||||
|
|
||||||
exports.fetch = async function (ctx) {
|
exports.fetch = async function (ctx) {
|
||||||
|
// Check if structure of call makes sense, if not, return error
|
||||||
|
|
||||||
|
|
||||||
|
// Read File
|
||||||
|
const fileContent = await getEnvironmentVariables()
|
||||||
|
const keys = await extractKeys(fileContent)
|
||||||
|
|
||||||
// Temporary while "real" infrastructure to store keys is created
|
// Temporary while "real" infrastructure to store keys is created
|
||||||
ctx.status = 200
|
ctx.status = 200
|
||||||
ctx.message = "API Keys"
|
ctx.message = "API Keys"
|
||||||
|
@ -24,17 +26,14 @@ exports.update = async function (ctx) {
|
||||||
ctx.body = { [ctx.params.key]: ctx.request.body.value }
|
ctx.body = { [ctx.params.key]: ctx.request.body.value }
|
||||||
}
|
}
|
||||||
|
|
||||||
const checkAccessLevel = async (db, accessLevelId) => {
|
async function getEnvironmentVariables() {
|
||||||
if (!accessLevelId) return
|
const home = require('os').homedir();
|
||||||
if (
|
const filePath = `${home}/${ENV_FILE_PATH}`
|
||||||
accessLevelId === POWERUSER_LEVEL_ID ||
|
|
||||||
accessLevelId === ADMIN_LEVEL_ID
|
return data = fs.readFileSync(filePath, 'utf8');
|
||||||
) {
|
|
||||||
return {
|
|
||||||
_id: accessLevelId,
|
|
||||||
name: accessLevelId,
|
|
||||||
permissions: [],
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return await db.get(accessLevelId)
|
async function extractKeys() {
|
||||||
|
// Extract keys here
|
||||||
|
return []
|
||||||
}
|
}
|
Loading…
Reference in New Issue