From 37c9dba689262b9e9401efc5bfec1481342cdaff Mon Sep 17 00:00:00 2001 From: Francois Best Date: Tue, 7 May 2024 19:53:16 +0200 Subject: [PATCH] chore: Remove env option 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. --- src/index.ts | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/src/index.ts b/src/index.ts index 1dc7454..63de7fa 100644 --- a/src/index.ts +++ b/src/index.ts @@ -3,11 +3,9 @@ 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' @@ -15,7 +13,7 @@ import sentry, { SentryOptions } from './sentry' declare module 'fastify' { interface FastifyInstance { name?: string - env: ReturnType + env: FastifyMicroEnv } } @@ -27,8 +25,6 @@ export type Options = Omit, 'https'> & { */ name?: string - env?: Record - /** * Enable HTTPS for your server by passing a TLS configuration. * Disabled by default. @@ -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),