Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
HadiMardanian authored Oct 3, 2021
1 parent c754856 commit e84cb23
Showing 1 changed file with 49 additions and 2 deletions.
51 changes: 49 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,51 @@

# fastify-dotenv
<h1 align="center">fastify-dotenv</h1>
<p align="center"><project-description></p>

fastify-dotenv iterate over your .env file and converts it to a **decorator** named *env*




## simple demo


<img src="assets/image.png">

## Usage/Examples

```javascript

const Fastify = require('fastify').fastify; // i used v3.21.6 here
const fastify = Fastify();
const dotenv = require('@hadimardanian/fastify-dotenv');

fastify.register(dotenv, {
path: '/config/.env', // (1)
decorator: 'env' // (2)
})

fastify.listen(4000, function serverListen() {
console.log('server is running on port ' + fastify.env)
})

```



## some tips

- (1) **path** : the "**/**" means the root of project folder. it must be at the beginning of path
- (2) **decorator** : name it whatever you want, if omitted it will be "**env**"
- the "**.env**" file: Its name could be everything. but its format must be plain text and content must be like following:



### .env file content

> port=4000
> mngodb=mongodb://localhost/mydb
> NODE_ENV=production

0 comments on commit e84cb23

Please sign in to comment.