Skip to content

Commit

Permalink
docs: fix 'PORT' datatype in the usage examples (#104)
Browse files Browse the repository at this point in the history
* docs: fix 'PORT' datatype in the usage example

* docs: fix 'fluent-json-schema' datatype for the 'port' property

* docs: fix expected output

* docs: fix 'PORT' property datatype for the 'Env' interface

* docs: remove semicolons in code examples

* docs: fix default value for the 'port' property
  • Loading branch information
batovpasha authored Jan 14, 2022
1 parent fca0cdd commit a0c000c
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const schema = {
required: [ 'PORT' ],
properties: {
PORT: {
type: 'string',
type: 'number',
default: 3000
}
}
Expand Down Expand Up @@ -111,7 +111,7 @@ const envSchema = require('env-schema')
const S = require('fluent-json-schema')

const config = envSchema({
schema: S.object().prop('port', S.string().default('3000').required()),
schema: S.object().prop('port', S.number().default(3000).required()),
data: data, // optional, default: process.env
dotenv: true, // load .env if it is there, default: false
expandEnv: true, // use dotenv-expand, default: false
Expand Down Expand Up @@ -192,7 +192,7 @@ const config = envSchema({
})

console.log(config)
// output: { PORT: 3000 }
// output: { names: ['foo', 'bar'] }
```

### TypeScript
Expand All @@ -203,7 +203,7 @@ You can specify the type of your `config`:
import envSchema from 'env-schema';

interface Env {
PORT: string
PORT: number;
}

const schema = {
Expand All @@ -215,7 +215,7 @@ const schema = {
default: 3000
}
}
};
}

const config = envSchema<Env>({
schema,
Expand All @@ -227,7 +227,7 @@ If no type is specified the `config` will have the `EnvSchemaData` type.
```ts
export type EnvSchemaData = {
[key: string]: unknown;
};
}
```
## Acknowledgements
Expand Down

0 comments on commit a0c000c

Please sign in to comment.