![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
nuxt-envalid
Advanced tools
A Nuxt.js module thats validates your env variables and loads them cleaned into your application context
A Nuxt.js module thats validates your env variables and loads them cleaned into your application context. Uses envalid under the hood.
nuxt-envalid
dependency to your projectyarn add --dev nuxt-envalid # or npm install --save-dev nuxt-envalid
nuxt-envalid
to the buildModules
section of nuxt.config.js
:warning: If you are using a Nuxt version previous than v2.9 you have to install module as a dependency
(No --dev
or --save-dev
flags) and also use modules
section in nuxt.config.js
instead of buildModules
.
export default {
buildModules: ['nuxt-envalid'],
};
export default {
buildModules: [
[
'nuxt-envalid',
{
/* module options */
},
],
],
};
export default {
buildModules: ['nuxt-envalid'],
envalid: {
/* module options */
},
};
export default {
buildModules: [
[
'nuxt-envalid',
() => ({
/* module options */
}),
],
],
/* or at top level */
envalid: () => ({
/* module options */
}),
};
Defining module options inline will overwrite module options defined at top level.
specs
{ [key: string]: ValidatorSpec }
{}
For further information take a look at the official documentation of envalid.
import { bool, str } from 'nuxt-envalid';
export default {
env: {
TITLE: 'title',
IS_PUBLIC: true,
},
buildModules: ['nuxt-envalid'],
envalid: {
specs: {
TITLE: str(),
SUBTITLE: str({ default: 'subtitle' }),
IS_PUBLIC: bool({ default: false }),
},
},
};
options
CleanOptions
{}
For further information take a look at the official documentation of envalid.
export default {
buildModules: ['nuxt-envalid'],
envalid: {
specs: {
TITLE: str(),
},
options: {
reporter: ({ errors, env }) => {
console.log(errors, env);
},
},
},
};
After creating your .env file in the project root, simply run your usual yarn dev
or npm run dev
.
The variable inside the .env file will be added to the context (context.env
) and process (process.env
).
This module will validate the result of @nuxtjs/dotenv
as well and then overwrite the values of the variables defined in the specs
. Be sure to include this module AFTER @nuxtjs/dotenv
.
# .env file
TITLE='title'
IS_PUBLIC=true
export default {
buildModules: ['@nuxtjs/dotenv', 'nuxt-envalid'],
envalid: {
specs: {
TITLE: str(),
SUBTITLE: str({ default: 'subtitle' }),
IS_PUBLIC: bool({ default: false }),
},
},
};
FAQs
A Nuxt.js module thats validates your env variables and loads them cleaned into your application context
The npm package nuxt-envalid receives a total of 21 weekly downloads. As such, nuxt-envalid popularity was classified as not popular.
We found that nuxt-envalid demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.