diff --git a/README.md b/README.md index 69938fc..fd97e1a 100644 --- a/README.md +++ b/README.md @@ -49,27 +49,11 @@ coffee.set("requests.limit" , 100); coffee.has("requests.limit"); // true ``` -## Customize Coffee Load -coffee can read the configurations from the desired directory. -``` -- coffee.ts -- custom - - default.json -``` -```ts -// coffee.ts -import coffee from "https://deno.land/x/coffee/mod.ts"; -coffee.load({ - configDir: "./custom", // specify the custom config directory - customEnvVarFileName: "cev", // specify the desired custom environment variable config file name - env: "production" // force relative environment variables to loads from this env -},); -const dbName: string = coffee.get("database.name").string(); -``` - ## Custom Environment Variables If you want to use environment variables, just create a file called `custom-environment-variable` and give it values that you want to read from environment variables. ```json +ENV_NAME=coffee + - coffee.ts - config - custom-environment-variables.json @@ -82,7 +66,7 @@ If you want to use environment variables, just create a file called `custom-envi ```ts // coffee.ts import coffee from "https://deno.land/x/coffee/mod.ts"; -const name: string = coffee.get("database.name").string(); +const name: string = coffee.get("database.name").string(); // coffee, reads from ENV_NAME environment variable ``` ## Related Environment Variables @@ -105,6 +89,26 @@ import coffee from "https://deno.land/x/coffee/mod.ts"; const name: string = coffee.get("something").string(); ``` +## Customize Coffee Load +coffee can read the configurations from the desired directory. +``` +- coffee.ts +- custom + - default.json + - cev.json + - production.json +``` +```ts +// coffee.ts +import coffee from "https://deno.land/x/coffee/mod.ts"; +coffee.load({ + configDir: "./custom", // specify the custom config directory + customEnvVarFileName: "cev", // specify the desired custom environment variable config file name + env: "production" // force relative environment variables to loads from this env +},); +const dbName: string = coffee.get("database.name").string(); +``` + ## Error Handling coffee tries to make a specific Error for each situation. ```ts diff --git a/examples/coffee.ts b/examples/coffee.ts index 8448693..fb3b3f7 100644 --- a/examples/coffee.ts +++ b/examples/coffee.ts @@ -1,4 +1,4 @@ -import coffee from "../mod.ts"; +import coffee from "https://deno.land/x/coffee/mod.ts"; // if coffee.load() is not called, coffee automatically loads the configs from the './config' folder diff --git a/examples/errorHandling.ts b/examples/errorHandling.ts index 002837d..5b0883e 100644 --- a/examples/errorHandling.ts +++ b/examples/errorHandling.ts @@ -1,4 +1,4 @@ -import coffee, { errors } from "../mod.ts"; +import coffee, { errors } from "https://deno.land/x/coffee/mod.ts"; // No Config Dir :