Skip to content

Commit

Permalink
remove .env.development
Browse files Browse the repository at this point in the history
  • Loading branch information
arily committed Jul 3, 2023
1 parent c595bd3 commit 1c7d30c
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 15 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,6 @@ celerybeat.pid

# Environments
.env
.env.development
.venv
env/
venv/
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ Guccho is a web interface to interact with osu private servers with compatibilit
## Setup

- Config .env *important*
for production, create .env from .env.example.
for development please create both .env and .env.development. `build` will use `.env` as environments to ensure you don't made any secrets to the public.
create .env from .env.example.

- Run `yarn`
- Run `yarn build:hljs`
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
"build:hljs": "node scripts/gen-hljs.mjs",
"build:gen": "yarn build:schemas & yarn build:hljs",
"build:all": "yarn build:gen && yarn build",
"dev": "nuxi --dotenv .env.development dev",
"dev": "nuxi dev",
"generate": "nuxi generate",
"start:prod": "dotenv -e .env node .output/server/index.mjs",
"start:dev:inspect": "dotenv -e .env.development node -- --inspect .output/server/index.mjs",
"start:dev:inspect": "dotenv -e .env node -- --inspect .output/server/index.mjs",
"analyze": "nuxi analyze",
"postinstall": "nuxi prepare",
"typecheck": "nuxi typecheck",
Expand Down
24 changes: 15 additions & 9 deletions src/server/env/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import type { ZodType, z } from 'zod'
import { ZodError, literal, object, string, union } from 'zod'
import { fromZodError } from 'zod-validation-error'
import { zodFQDN, zodPath } from '~/server/trpc/shapes'
import { Logger } from '$base/log'

const logger = Logger.child({ label: 'env' })

export const database = literal('database')
export const memory = literal('memory')
Expand Down Expand Up @@ -65,18 +68,21 @@ export function ensureAndGetEnv<Z extends ZodType>(zod: Z): z.infer<Z> {
}
catch (e) {
if (!(e instanceof ZodError)) {
logger.error(e)
throw e
}
const formattedZodError = fromZodError(
e,
{
prefix: 'env validation error:\n',
prefixSeparator: '',
issueSeparator: ';\n',
unionSeparator: ',\n',
}
)
logger.error(formattedZodError)
throw new Error(
fromZodError(
e,
{
prefix: 'env validation error:\n',
prefixSeparator: '',
issueSeparator: ';\n',
unionSeparator: ',\n',
}
).message
formattedZodError.message
)
}
}
2 changes: 1 addition & 1 deletion src/server/trpc/routers/me.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ export const router = _router({
if (err.message === 'has-relationship') {
throw new TRPCError({
code: 'CONFLICT',
message: 'need to delete old relation before create new',
message: 'you have existing relations, delete old one first.',
})
}
}
Expand Down

0 comments on commit 1c7d30c

Please sign in to comment.