Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions app/constants.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
import { minLength } from "remix/data-schema/checks"

import * as s from "./utils/local-schema.ts"

const envSchema = s.object({
SESSION_SECRET: s.string().pipe(minLength(1)),
DATABASE_URL: s.string().pipe(minLength(1)),
REDIS_URL: s.string().pipe(minLength(1)),
NODE_ENV: s.enum_(["development", "production", "test"]),
})

export const env = s.parse(envSchema, process.env)
export const WORD_LENGTH = 5
export const LETTER_INPUTS = [...Array(WORD_LENGTH).keys()]
export const TOTAL_GUESSES = 6
Expand Down
12 changes: 12 additions & 0 deletions app/env.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { minLength } from "remix/data-schema/checks"

import * as s from "./utils/local-schema.ts"

const envSchema = s.object({
SESSION_SECRET: s.string().pipe(minLength(1)),
DATABASE_URL: s.string().pipe(minLength(1)),
REDIS_URL: s.string().pipe(minLength(1)),
NODE_ENV: s.enum_(["development", "production", "test"]),
})

export const env = s.parse(envSchema, process.env)
4 changes: 2 additions & 2 deletions app/utils/db.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { PrismaPg } from "@prisma/adapter-pg"
import Redis from "ioredis"

import { env } from "#app/constants.ts"
import { env } from "#app/env.ts"
import { PrismaClient } from "#app/generated/prisma/client.ts"

const adapter = new PrismaPg({ connectionString: process.env.DATABASE_URL })
const adapter = new PrismaPg({ connectionString: env.DATABASE_URL })
export const db = new PrismaClient({ adapter })

export const redis = new Redis(env.REDIS_URL, {
Expand Down
2 changes: 1 addition & 1 deletion app/utils/queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { ConnectionOptions } from "bullmq"
import { Queue, Worker } from "bullmq"
import { startOfDay } from "date-fns"

import { env } from "#app/constants.ts"
import { env } from "#app/env.ts"

import { db } from "./db.ts"

Expand Down
2 changes: 1 addition & 1 deletion app/utils/session.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createCookie } from "remix/cookie"
import { createCookieSessionStorage } from "remix/session/cookie-storage"

import { env } from "#app/constants.ts"
import { env } from "#app/env.ts"

export const sessionCookie = createCookie("session", {
secrets: [env.SESSION_SECRET],
Expand Down
Loading