2020-07-29 02:08:38 +03:00
|
|
|
import { runQuery } from "~/node_common/data/utilities";
|
|
|
|
|
|
|
|
export default async ({ key }) => {
|
|
|
|
return await runQuery({
|
|
|
|
label: "GET_API_KEY_BY_KEY",
|
|
|
|
queryFn: async (DB) => {
|
2020-09-13 01:08:36 +03:00
|
|
|
const query = await DB.select("*").from("keys").where({ key }).first();
|
2020-07-29 02:08:38 +03:00
|
|
|
|
|
|
|
if (!query || query.error) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (query.id) {
|
2020-08-25 09:46:02 +03:00
|
|
|
return JSON.parse(JSON.stringify(query));
|
2020-07-29 02:08:38 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
},
|
|
|
|
errorFn: async (e) => {
|
|
|
|
return {
|
2020-09-13 01:08:36 +03:00
|
|
|
error: true,
|
|
|
|
decorator: "GET_API_KEY_BY_KEY",
|
2020-07-29 02:08:38 +03:00
|
|
|
};
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|