Skip to content

Commit

Permalink
fix: minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
hywax committed Jun 19, 2024
1 parent d57a157 commit 7155754
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 15 deletions.
6 changes: 3 additions & 3 deletions src/lib/date.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
export function getDatePlusMinutes(minutes: number) {
export function getDatePlusMinutes(minutes: number): Date {
const milliseconds = minutes * 60 * 1000
return new Date(new Date().getTime() + milliseconds)
}

export function getDateMinusMinutes(minutes: number) {
export function getDateMinusMinutes(minutes: number): Date {
const milliseconds = minutes * 60 * 1000
return new Date(new Date().getTime() - milliseconds)
}

export function getDatePlusSeconds(seconds: number) {
export function getDatePlusSeconds(seconds: number): Date {
const milliseconds = seconds * 1000
return new Date(new Date().getTime() + milliseconds)
}
2 changes: 1 addition & 1 deletion src/lib/locale.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export function ruWordWithEndings(
int: number,
array: [string, string, string],
) {
): string {
return array[
int % 100 > 4 && int % 100 < 20
? 2
Expand Down
16 changes: 6 additions & 10 deletions src/routes/(website)/auth/sign-in/+server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,19 @@ import { error, json } from '@sveltejs/kit'
import { ApiClient } from '@twurple/api'
import { StaticAuthProvider, getTokenInfo } from '@twurple/auth'
import jwt from 'jsonwebtoken'
import type { Profile } from '@prisma/client'
import type { RequestHandler } from './$types'
import type { IProfile } from '$lib/types'
import { db } from '$lib/server/db/db.client'
import { env as publicEnv } from '$env/dynamic/public'
import { env as privateEnv } from '$env/dynamic/private'

async function findOrCreateProfile({
twitchId,
userName,
}: {
twitchId: string
userName: string
}) {
const profileInDB = await db.profile.findFirst({
async function findOrCreateProfile({ twitchId, userName }: Pick<Profile, 'twitchId' | 'userName'>): Promise<Profile> {
const profile = await db.profile.findFirst({
where: { twitchId },
})
if (!profileInDB) {

if (!profile) {
return db.profile.create({
data: {
id: createId(),
Expand All @@ -29,7 +25,7 @@ async function findOrCreateProfile({
})
}

return profileInDB
return profile
}

async function prepareJwtToken(accessToken: string) {
Expand Down
3 changes: 2 additions & 1 deletion src/routes/(website)/character/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import { db } from '$lib/server/db/db.client'

export const load: PageServerLoad = async () => {
const characters = await db.character.findMany()
if (!characters) {

if (!characters.length) {
error(404, 'Not found')
}

Expand Down
1 change: 1 addition & 0 deletions src/routes/(website)/character/[slug]/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export const load: PageServerLoad = async ({ params }) => {
const character = await db.character.findFirst({
where: { id },
})

if (!character) {
error(404, 'Not found')
}
Expand Down

0 comments on commit 7155754

Please sign in to comment.