UNPKG

based-auth

Version:

A Next.js/Node.js authentication and wallet API kit for Ethereum and Solana, with utilities for serialization and contract interaction, designed for serverless and API route usage.

146 lines (145 loc) 2.77 kB
import l, { Schema as c, models as p, model as f } from "mongoose"; import { N as s } from "./sui-C9kTe4me.mjs"; const t = { connection: null, promise: null }, m = async (r = { uri: process.env.MONGO_URI || "", options: {} }) => { try { if (!r.uri) throw new Error("MONGO_URI environment variable is not set"); if (t.connection) return; if (!t.promise) { const e = {}; t.promise = l.connect(r.uri, e); } try { t.connection = await t.promise; } catch (e) { throw t.promise = null, e; } } catch (e) { throw console.error("MongoDB connection error:", e), e; } }, a = new c( { name: { type: String, default: "", required: !0, index: !0 }, bio: { type: String, default: "" }, image: { type: String, default: "" }, banner: { type: String, default: "" }, metaInfo: { website: { type: String, default: "" }, twitter: { type: String, default: "" }, telegram: { type: String, default: "" }, discord: { type: String, default: "" } }, lastNetwork: { type: String, default: "" }, lastSignedIn: { type: Date, default: Date.now }, lastAddress: { type: String, default: "" }, followers: [ { network: { type: String, enum: Object.values(s), required: !0 }, address: { type: String, required: !0 } } ], users: [ { network: { type: String, enum: Object.values(s), required: !0 }, address: { type: String, required: !0 }, social: { type: String, default: "" }, provider: { type: String, default: "" } } ] }, { timestamps: !0, toObject: { getters: !0, versionKey: !1, transform: (r, e) => { const { _id: o, __v: y, ...u } = e; return e = u, e.id = o.toString(), e.users = e.users.map(({ _id: d, ...n }) => ({ ...n })), e.followers = e.followers.map(({ _id: d, ...n }) => ({ ...n })), e; } } } ); a.index( { "users.network": 1, "users.address": 1 }, { unique: !0 } ); var i; const g = ((i = p) == null ? void 0 : i.UserProfile) || f("UserProfile", a); async function b(r, e) { return await m(), await g.findOne({ "users.address": r, "users.network": e }); } export { g as U, m as c, b as g }; //# sourceMappingURL=get-user-profile-CmCpyzpL.mjs.map