mirror of
https://github.com/filecoin-project/slate.git
synced 2024-12-01 22:56:35 +03:00
28 lines
771 B
JavaScript
28 lines
771 B
JavaScript
import * as Serializers from "~/node_common/serializers";
|
|
import { runQuery } from "~/node_common/data/utilities";
|
|
|
|
//NOTE(toast): should only be used for checking if an email is taken
|
|
//ALWAYS sanitize it before sending result to frontend
|
|
export default async ({ twitterId }) => {
|
|
return await runQuery({
|
|
label: "GET_USER_BY_TWITTER_ID",
|
|
queryFn: async (DB) => {
|
|
let query = await DB.select("*").from("users").where({ twitterId: twitterId }).first();
|
|
|
|
if (!query || query.error) {
|
|
return null;
|
|
}
|
|
|
|
query = Serializers.sanitizeUser(query);
|
|
|
|
return JSON.parse(JSON.stringify(query));
|
|
},
|
|
errorFn: async (e) => {
|
|
return {
|
|
error: true,
|
|
decorator: "GET_USER_BY_TWITTER_ID",
|
|
};
|
|
},
|
|
});
|
|
};
|