Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

classenv

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

classenv - npm Package Compare versions

Comparing version 1.2.0 to 1.2.1

2

dist/env.d.ts

@@ -1,1 +0,1 @@

export declare function Env(name: string): any;
export declare function Env(inputName?: string): any;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function Env(name) {
function Env(inputName) {
return (target, key) => {
const name = inputName !== null && inputName !== void 0 ? inputName : key
.split(/(?=[A-Z])/)
.join('_')
.toUpperCase();
let value = process.env[name];
if (typeof value === 'undefined') {
if (typeof target[key] === 'undefined') {
throw new Error(`Environment variable ${name} is undefined`);
}
else {
value = target[key];
}
}
const designType = Reflect.getMetadata('design:type', target, key);
if ([String, Number, Boolean].includes(designType)) {
if (typeof process.env[name] === 'undefined') {
throw new Error(`Environment variable ${name} is undefined`);
}
Object.defineProperty(target, key, {
value: designType(process.env[name]),
value: designType(value),
writable: false,

@@ -13,0 +23,0 @@ enumerable: true,

@@ -0,1 +1,7 @@

"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
Object.defineProperty(exports, "__esModule", { value: true });
__export(require("./env"));
//# sourceMappingURL=index.js.map
{
"name": "classenv",
"version": "1.2.0",
"version": "1.2.1",
"description": "Describe your environment variables contract with TypeScript class",

@@ -10,3 +10,6 @@ "main": "dist/index.js",

"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"build": "tsc",
"test": "npx jest",
"prebuild": "rm -rf ./dist",
"prepublish": "npm run build"
},

@@ -23,6 +26,8 @@ "author": "bowzee",

"prettier": "^2.0.2",
"reflect-metadata": "^0.1.13",
"ts-jest": "^25.2.1",
"typescript": "^3.8.3"
},
"peerDependencies": {
"reflect-metadata": "^0.1.13"
},
"keywords": [

@@ -29,0 +34,0 @@ "dotenv",

@@ -8,3 +8,2 @@ # classenv

- Auto UPPER_SNAKE_CASE conversion
- 0 dependencies
- Throws runtime error if variable doesn't exist

@@ -56,1 +55,24 @@ - Default values support

`@Env` property data type should be scalar (string, number or boolean).
## Dependencies
###reflect-metadata
```
npm i reflect-metadata
```
And then import it somewhere close to your entry point (`index.ts`/`main.ts`/etc...).
Should be imported before any of your environment classes.
```typescript
import 'reflect-metadata';
```
###tsconfig.json
These settings should be enabled
```
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
```

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc