Skip to content

Commit

Permalink
docs(package): better README and more jsdocs everywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
mrspartak committed Jun 18, 2024
1 parent c38bd6d commit 23349f1
Show file tree
Hide file tree
Showing 34 changed files with 444 additions and 127 deletions.
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) [year] [fullname]

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
56 changes: 37 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,43 @@
# Typescript runtime configuration resolver

@mrspartak/config is a robust TypeScript runtime configuration resolver designed to ensure that your application runs with the correct settings every time. It supports dynamic runtime validation, deep merging of configurations, and integrates seamlessly with your choice of data validation libraries.

![GitHub Release](https://img.shields.io/github/v/release/mrspartak/config?style=for-the-badge&color=%231b1b1f)
![npm bundle size (scoped)](https://img.shields.io/bundlephobia/min/%40mrspartak/config?style=for-the-badge&color=%231b1b1f)
![NPM Downloads](https://img.shields.io/npm/dw/%40mrspartak%2Fconfig?style=for-the-badge&color=%231b1b1f)

* ⚡️ Runtime validation (no more deployments with the wrong configuration)
* 🧙‍♂️ TypeScript intelissense
* 🍃 Light, zero external dependencies
* 🤲 Merge configurations (defaults overwrite strategy)
* 👓 Support for JSON file/url config, Object config, [soon] ENV
* 🐻 Bring your validator library of choise. We support **Zod**, **Valibot**, **Yup**, **Superstruct** etc...
* ✅ Well-tested and production ready.
* [soon] Works as a run-time config provider on a front-end
* ⚡️ Runtime Validation: Ensure your application never runs with the wrong configuration.
* 🧙‍♂️ TypeScript IntelliSense: Leverage auto-completion and type-checking at development time.
* 🍃 Zero Dependencies: Lightweight with no external dependencies
* 🤲 Flexible Configuration Merging: Supports merging multiple configurations with a default overwrite strategy.
* 👓 Versatile Configuration Sources: Load from JSON files, URLs, or direct objects.
* 🐻 Extensible Validation Support: Compatible with **Zod**, **Valibot**, **Yup**, **Superstruct**, and more.
* ✅ Production Ready: Thoroughly tested and stable for use.

## Roadmap

* 📁 Support for .env files.
* 🌐 Enhance front-end compatibility.
* 📚 Expand documentation.
* ⚙️ Integrate GitHub Actions for test coverage reporting.

## Quickstart
## Installation
```sh
# yarn
yarn add @mrspartak/config

# npm
npm i @mrspartak/config

# pnpm
pnpm add @mrspartak/config

# bun
bun add @mrspartak/config
```

## Usage
## Quick Start

1. Create a config resolver file
Create a config resolver file
```ts
// file: state/config.ts
import { fromJSONFile } from "@mrspartak/config";
import * as z from "zod"

Expand All @@ -53,10 +59,22 @@ const config = await fromJSONFile({
export default config
```

2. Import resolved configuration anywhere you need
Import resolved configuration anywhere you need
```ts
import config from 'config.js'
import db from 'some-db-provider'
// file: index.ts
// Import your resolved configuration
import config from './state/config.js';

// Use the configuration in your application
import db from 'some-db-provider';
const dbClient = db(config.db); // Enjoy IntelliSense here!
```

Full documentation is generated from TS declaration avialable here: https://mrspartak.github.io/config/

## Contributing
I welcome contributions from the community! Whether it's improving the documentation, adding new features, or reporting bugs, please feel free to make a pull request or open an issue.

const dbClient = db(config.db) // config.db will have full intelisense
```
## License
This project is licensed under the MIT License - see the LICENSE.md file for details.

7 changes: 7 additions & 0 deletions docs/assets/highlight.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
--dark-hl-7: #4FC1FF;
--light-hl-8: #098658;
--dark-hl-8: #B5CEA8;
--light-hl-9: #267F99;
--dark-hl-9: #4EC9B0;
--light-code-background: #FFFFFF;
--dark-code-background: #1E1E1E;
}
Expand All @@ -31,6 +33,7 @@
--hl-6: var(--light-hl-6);
--hl-7: var(--light-hl-7);
--hl-8: var(--light-hl-8);
--hl-9: var(--light-hl-9);
--code-background: var(--light-code-background);
} }

Expand All @@ -44,6 +47,7 @@
--hl-6: var(--dark-hl-6);
--hl-7: var(--dark-hl-7);
--hl-8: var(--dark-hl-8);
--hl-9: var(--dark-hl-9);
--code-background: var(--dark-code-background);
} }

Expand All @@ -57,6 +61,7 @@
--hl-6: var(--light-hl-6);
--hl-7: var(--light-hl-7);
--hl-8: var(--light-hl-8);
--hl-9: var(--light-hl-9);
--code-background: var(--light-code-background);
}

Expand All @@ -70,6 +75,7 @@
--hl-6: var(--dark-hl-6);
--hl-7: var(--dark-hl-7);
--hl-8: var(--dark-hl-8);
--hl-9: var(--dark-hl-9);
--code-background: var(--dark-code-background);
}

Expand All @@ -82,4 +88,5 @@
.hl-6 { color: var(--hl-6); }
.hl-7 { color: var(--hl-7); }
.hl-8 { color: var(--hl-8); }
.hl-9 { color: var(--hl-9); }
pre, code { background: var(--code-background); }
8 changes: 4 additions & 4 deletions docs/coverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 15 additions & 1 deletion docs/functions/fromJSONFile.html

Large diffs are not rendered by default.

Loading

0 comments on commit 23349f1

Please sign in to comment.