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.4 to 1.3.0

2

dist/env.d.ts

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

export declare function Env(inputName?: string): any;
export declare function Env(variableName?: string): any;
//# sourceMappingURL=env.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function Env(inputName) {
exports.Env = void 0;
function upperSnakeCase(str) {
return str.split(/(?=[A-Z])/)
.join('_')
.toUpperCase();
}
function Env(variableName) {
return (target, key) => {
const name = inputName !== null && inputName !== void 0 ? inputName : key
.split(/(?=[A-Z])/)
.join('_')
.toUpperCase();
let value = process.env[name];
variableName !== null && variableName !== void 0 ? variableName : (variableName = upperSnakeCase(variableName));
let value = process.env[variableName];
if (typeof value === 'undefined') {
if (typeof target[key] === 'undefined') {
throw new Error(`Environment variable ${name} is undefined`);
throw new Error(`Environment variable ${variableName} is undefined`);
}

@@ -20,2 +23,8 @@ else {

if ([String, Number, Boolean].includes(designType)) {
if (designType === Boolean && ['false', '0'].includes(value)) {
value = false;
}
else {
value = designType(value);
}
Object.defineProperty(target, key, {

@@ -22,0 +31,0 @@ value: designType(value),

"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__export(require("./env"));
__exportStar(require("./env"), exports);
//# sourceMappingURL=index.js.map
{
"name": "classenv",
"version": "1.2.4",
"version": "1.3.0",
"description": "Describe your environment variables contract with TypeScript class",

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

"scripts": {
"build": "tsc",
"build": "tsc -p tsconfig.build.json",
"test": "npx jest",

@@ -25,6 +25,7 @@ "prebuild": "rm -rf ./dist",

"@types/jest": "^25.1.4",
"@types/node": "^17.0.31",
"jest": "^25.1.0",
"prettier": "^2.0.2",
"ts-jest": "^25.2.1",
"typescript": "^3.8.3"
"typescript": "^4.6.4"
},

@@ -31,0 +32,0 @@ "peerDependencies": {

@@ -6,8 +6,9 @@ # classenv

- Strongly-typed declarative class containing your environment data
- Supports both static and instance properties
- Type-casting using TypeScript metadata reflection
- Auto UPPER_SNAKE_CASE conversion
- Converts environment values "FALSE", "false", "0" to false for boolean types
- Throws runtime error if variable doesn't exist
- Default values support
- Makes decorated properties read-only in runtime
- Supports both static and instance properties

@@ -81,3 +82,3 @@

###reflect-metadata
### reflect-metadata
```

@@ -94,3 +95,3 @@ npm i reflect-metadata

###tsconfig.json
### tsconfig.json

@@ -102,2 +103,2 @@ These settings should be enabled

"experimentalDecorators": true,
```
```

Sorry, the diff of this file is not supported yet

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