Skip to content

Commit

Permalink
chore: Remove env option
Browse files Browse the repository at this point in the history
Merging of envs may need to be done at the module top-level
in consuming apps to be exposed to scripts
like database migrations.
Moreover, the server.env decoration can be overriden.
  • Loading branch information
franky47 committed May 7, 2024
1 parent 6c3c503 commit 37c9dba
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,17 @@ import sensible from '@fastify/sensible'
import underPressurePlugin, {
UnderPressureOptions
} from '@fastify/under-pressure'
import { createEnv } from '@t3-oss/env-core'
import Fastify, { FastifyHttpsOptions, FastifyInstance } from 'fastify'
import https from 'node:https'
import { ZodType } from 'zod'
import { fastifyMicroEnv } from './environment'
import { fastifyMicroEnv, type FastifyMicroEnv } from './environment'
import gracefulShutdown, { GracefulShutdownOptions } from './graceful-shutdown'
import { getLoggerOptions, makeReqIdGenerator } from './logger'
import sentry, { SentryOptions } from './sentry'

declare module 'fastify' {
interface FastifyInstance {
name?: string
env: ReturnType<typeof fastifyMicroEnv>
env: FastifyMicroEnv
}
}

Expand All @@ -27,8 +25,6 @@ export type Options = Omit<FastifyHttpsOptions<https.Server>, 'https'> & {
*/
name?: string

env?: Record<string, ZodType>

/**
* Enable HTTPS for your server by passing a TLS configuration.
* Disabled by default.
Expand Down Expand Up @@ -116,12 +112,7 @@ export function createServer(
https: null
}
) {
const env = createEnv({
server: options.env ?? {},
extends: [fastifyMicroEnv()],
runtimeEnv: process.env,
isServer: true
})
const env = fastifyMicroEnv()
const server = Fastify({
logger: getLoggerOptions(options, env),
genReqId: makeReqIdGenerator(env),
Expand Down

0 comments on commit 37c9dba

Please sign in to comment.