codechaotic / eznv Goto Github PK
View Code? Open in Web Editor NEWEnv Management without Fuss
Env Management without Fuss
Excluding the options object from a call to Schema.load()
or Schema.loadSync()
results in a typescript error.
Expected 1 arguments, but got 0.
These methods should be callable without supplying an options object since all options have safe defaults.
Current documentation is minimal and could be improved
Add an ability to add custom validation to any configuration
Add an ability to transform the resulting configuration value
Method 1: Dedicated validation and transform function as an option for interpreters. There doesn't seem to be an obvious return value for the validator. Would it be better to provide special handling for errors thrown from within this method instead?
EZ.Number({
validate (x: string): boolean {
// return false or maybe just throw error?
}
transform (x: number): any {
// The return type of the transform method would need to be
// used on the resulting env object
}
})
Method 2: Singular function option to do any post-processing. Functions as both a validator and a transformer. Would it make sense to have a pre-processing function as an option as well? before
and after
, pre
and post
, or similar?
EZ.Integer({
after (x: number): any {
if (x % 2 === 1) throw new Error('Must be an even number')
else return x / 2
}
})
This may be solvable alongside #11
In addition to String, Number, Integer, and Boolean, users may have their own unique parsing rules to apply to their environment variables. This could include validation of the raw value, as well as custom result types.
Off the wall idea for the design:
import EZ from 'eznv'
interface SomeType {
//
}
const schema = EZ.Schema({
variable: EZ.Custom<SomeType>({
parse (x: string) : SomeType {
// custom parsing logic
return { /* some type */ }
}
})
})
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.