slate/node_common/data/methods/get-api-key.js

27 lines
547 B
JavaScript

import { runQuery } from "~/node_common/data/utilities";
export default async ({ id }) => {
return await runQuery({
label: "GET_API_KEY",
queryFn: async (DB) => {
const query = await DB.select("*").from("keys").where({ id }).first();
if (!query || query.error) {
return null;
}
if (query.id) {
return JSON.parse(JSON.stringify(query));
}
return null;
},
errorFn: async (e) => {
return {
error: true,
decorator: "GET_API_KEY",
};
},
});
};