We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Latest
18
Windows
11
For TS, the docs say that we just have to augment the fastify interface but I had to do more to get the plugin working without TS errors:
import FastifyEnv from '@fastify/env' import { JSONSchemaType } from 'env-schema' <redacted> type Env = { JWT_SECRET: string } const envSchema: JSONSchemaType<Env> = { type: 'object', properties: { JWT_SECRET: { type: 'string', }, }, required: ['JWT_SECRET'], additionalProperties: false, } const app: FastifyPluginAsync<AppOptions> = async ( fastify, opts ): Promise<void> => { await fastify.register(FastifyEnv, { schema: envSchema, dotenv: { path: path.join(__dirname, isProduction ? '.env' : '.env.development'), debug: isProduction === false, }, }) <redacted> }
Without all this, either the runtime was complaining about the schema passed to the options, or TS was complaining about the overload used.
Also, there was nothing in the docs about how to copy the .env file to dist/ - I know it's not directly your responsibility but would be nice to add.
.env
dist/
fastify-cli --lang=ts --esm
No response
The text was updated successfully, but these errors were encountered:
Thanks for reporting! Would you like to send a Pull Request to address this issue? It's likely just a docs issue.
Sorry, something went wrong.
@mcollina it's on my TODO :)
feat(backend): env typings and schema @fastify/env
d61e97a
extra: typescript extra stuff required fastify/fastify-env#171
No branches or pull requests
Prerequisites
Fastify version
Latest
Plugin version
Latest
Node.js version
18
Operating system
Windows
Operating system version (i.e. 20.04, 11.3, 10)
11
Description
For TS, the docs say that we just have to augment the fastify interface but I had to do more to get the plugin working without TS errors:
Without all this, either the runtime was complaining about the schema passed to the options, or TS was complaining about the overload used.
Also, there was nothing in the docs about how to copy the
.env
file todist/
- I know it's not directly your responsibility but would be nice to add.Steps to Reproduce
fastify-cli --lang=ts --esm
Expected Behavior
No response
The text was updated successfully, but these errors were encountered: