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
4.10.0
No response
20.12.2
Windows
23H2
import envSchema, { JSONSchemaType } from 'env-schema'; export interface Env { DATABASE_USER: string; DATABASE_PASSWORD: string; DATABASE_HOST: string; DATABASE_PORT: number; DATABASE_NAME: string; DATABASE_URL: string; } const schema: JSONSchemaType<Env> = { type: 'object', required: ['DATABASE_USER', 'DATABASE_PASSWORD', 'DATABASE_HOST', 'DATABASE_PORT', 'DATABASE_NAME', 'DATABASE_URL' ], properties: { DATABASE_USER: { type: 'string', }, DATABASE_PASSWORD: { type: 'string', }, DATABASE_HOST: { type: 'string', }, DATABASE_PORT: { type: 'number', }, DATABASE_NAME: { type: 'string', }, DATABASE_URL: { type: 'string', }, }, }; const env = envSchema({ dotenv: true, schema, }); console.log(env.DATABASE_URL); // result: mysql://${DATABASE_USER}:${DATABASE_PASSWORD}@${DATABASE_HOST}:${DATABASE_PORT}/${DATABASE_NAME}?ssl-mode=REQUIRED console.log(process.env.DATABASE_URL); // expected result: mysql://root:pass@localhost:3306/db_name?ssl-mode=REQUIRED
DATABASE_USER="root" DATABASE_PASSWORD="pass" DATABASE_HOST="localhost" DATABASE_PORT="3306" DATABASE_NAME="db_name" DATABASE_URL="mysql://${DATABASE_USER}:${DATABASE_PASSWORD}@${DATABASE_HOST}:${DATABASE_PORT}/${DATABASE_NAME}?ssl-mode=REQUIRED"
The text was updated successfully, but these errors were encountered:
We don't use any additional plugins, you need to add the https://www.npmjs.com/package/dotenv-expand one.
We may implement a plugins option in this plugin as we did for ajv https://fastify.dev/docs/latest/Reference/Validation-and-Serialization/#ajv-plugins but I would not add this dep to our dependancies.
plugins
Sorry, something went wrong.
Thank you for the suggestion. I added the dotenv-expand package, and it's now working properly.
dotenv-expand
No branches or pull requests
Prerequisites
Fastify version
4.10.0
Plugin version
No response
Node.js version
20.12.2
Operating system
Windows
Operating system version (i.e. 20.04, 11.3, 10)
23H2
Description
Link to code that reproduces the bug
No response
Expected Behavior
No response
The text was updated successfully, but these errors were encountered: