slate/node_common/data/methods/get-twitter-token.js

27 lines
577 B
JavaScript
Raw Normal View History

2021-06-09 01:53:30 +03:00
import { runQuery } from "~/node_common/data/utilities";
export default async ({ token }) => {
return await runQuery({
label: "GET_TWITTER_TOKEN",
queryFn: async (DB) => {
const query = await DB.select("*").from("twitterTokens").where({ token }).first();
if (!query || query.error) {
return null;
}
if (query.token) {
return JSON.parse(JSON.stringify(query));
}
return null;
},
errorFn: async (e) => {
return {
error: true,
decorator: "GET_TWITTER_TOKEN",
};
},
});
};