https://github.com/jamalam360/dynamo
A useful configuration library for Node & Deno applications.
https://github.com/jamalam360/dynamo
deno node typescript
Last synced: about 2 months ago
JSON representation
A useful configuration library for Node & Deno applications.
- Host: GitHub
- URL: https://github.com/jamalam360/dynamo
- Owner: Jamalam360
- License: mit
- Created: 2022-10-14T07:22:19.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-10-17T07:20:03.000Z (over 3 years ago)
- Last Synced: 2025-02-19T10:36:44.276Z (over 1 year ago)
- Topics: deno, node, typescript
- Language: TypeScript
- Homepage:
- Size: 29.3 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Dynamo
_Dynamo_ is a useful configuration library for Deno & Node applications, built
for use with TypeScript.
## Usage
Using Dynamo is very simple. It is available from both NPM (dynamo-config), and
deno.land/x (dynamo).
Node
```ts
import { Dynamo } from "dynamo-config";
// You can also use a type alias union-ed with Dynamo.Config
// if you wish.
interface ApplicationConfig extends Dynamo.Config {
verbose: boolean;
port?: number;
hostname?: string;
credentials: {
username: string;
password: string;
};
}
// We can pass defaults like so.
const defaults: Partial = {
port: 8080,
hostname: "localhost",
};
const config = await Dynamo.create({
file: "./config.yml",
defaults,
});
console.log(config.port);
// Reload can be called to reload the config from the filesystem.
await config.reload();
```
Deno
```ts
import * as Dynamo from "https://deno.land/x/dynamo/mod.ts";
// You can also use a type alias union-ed with Dynamo.Config
// if you wish.
interface ApplicationConfig extends Dynamo.Config {
verbose: boolean;
port?: number;
hostname?: string;
credentials: {
username: string;
password: string;
};
}
// We can pass defaults like so.
const defaults: Partial = {
port: 8080,
hostname: "localhost",
};
const config = await Dynamo.create({
file: "./config.yml",
defaults,
});
console.log(config.port);
// Reload can be called to reload the config from the filesystem.
await config.reload();
```
## Formats
By default, _Dynamo_ uses YAML for configuration, but it is designed to be
extendable. The `create` method takes an optional `parser` parameter with the
type `(content: string) => any`. This allows you to use any format you can
parse. _Dynamo_ includes extra parsers for different formats in the `parsers`
directory. For example, to use JSON:
```ts
import { json } from "https://deno.land/x/dynamo/parsers/json.ts";
const config = await Dynamo.create({
file: "./config.json",
parser: json,
});
```
To see the full list of parsers, see the `parsers` directory.
## Support
For support, open an [issue](https://github.com/Jamalam360/Dynamo/issues), or
contact me [on Discord](https://discord.jamalam.tech).
## License
_Dynamo_ is licensed under the MIT license.
```
```