GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — partypocket/lib/User.ts at main · schiemon/partypocket

This repository was archived by the owner on Jul 30, 2024. It is now read-only.

Expand file tree

/

User.ts

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
58 lines (52 loc) · 1.56 KB
/

User.ts

Copy path

File metadata and controls

58 lines (52 loc) · 1.56 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import prisma from "../lib/db";
import { User } from "@prisma/client";
import { ApiError } from "next/dist/server/api-utils";
import { StatusCodes } from "http-status-codes";
import AuthorizationError from "./error/AuthorizationError";
class UserError extends ApiError {
constructor(status: StatusCodes, message: string) {
super(status, message);
}
}
export class UserNotFoundError extends UserError {
constructor(status: StatusCodes, sub: string) {
const message = `Could not find user with subject field '${sub}'.`;
super(status, message);
}
}
export class UserNotHostError extends AuthorizationError {
constructor(userId: string, partyId: string) {
const message = `User '${userId}' is not host of the party '${partyId}'`;
super(message);
}
}
export class UserDoesNotHostGuestError extends AuthorizationError {
constructor(userId: string, partyId: string, guestId: string) {
const message = `User '${userId}' is not host of '${guestId}' in party '${partyId}'`;
super(message);
}
}
/*
Creates a user if it does not exist.
*/
export default async function createUser(sub: string): Promise<User> {
return prisma.user.upsert({
where: {
sub: sub,
},
update: {},
create: {
sub: sub,
},
});
}
/*
Finds user from its unique subject field given by the session.
*/
export async function getUser(sub: string): Promise<User | null> {
return prisma.user.findUnique({
where: {
sub: sub,
},
});
}
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.