mirror of
https://github.com/versia-pub/server.git
synced 2026-04-27 20:59:15 +02:00
refactor(cli): ♻️ Rewrite CLI with Clerk. Removes a bunch of commands now covered by API.
This commit is contained in:
parent
28577d017a
commit
5b756ea2dd
32 changed files with 536 additions and 2721 deletions
24
cli/utils.ts
Normal file
24
cli/utils.ts
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import { parseUserAddress } from "@/api";
|
||||
import { and, eq, isNull } from "drizzle-orm";
|
||||
import { Instance } from "~/classes/database/instance";
|
||||
import { User } from "~/classes/database/user";
|
||||
import { Users } from "~/drizzle/schema";
|
||||
|
||||
export const retrieveUser = async (
|
||||
usernameOrHandle: string,
|
||||
): Promise<User | null> => {
|
||||
const { username, domain } = parseUserAddress(usernameOrHandle);
|
||||
|
||||
const instance = domain ? await Instance.resolveFromHost(domain) : null;
|
||||
|
||||
const user = await User.fromSql(
|
||||
and(
|
||||
eq(Users.username, username),
|
||||
instance
|
||||
? eq(Users.instanceId, instance.data.id)
|
||||
: isNull(Users.instanceId),
|
||||
),
|
||||
);
|
||||
|
||||
return user;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue