mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-19 08:31:17 +08:00
[cloud-env] Add type declarations (#16772)
This commit is contained in:
committed by
Mohamed Hegazy
parent
1790ce0757
commit
3537f59e0b
9
types/cloud-env/cloud-env-tests.ts
Normal file
9
types/cloud-env/cloud-env-tests.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import * as cloudEnv from 'cloud-env';
|
||||
|
||||
if (cloudEnv.get('IP', '0.0.0.0') !== '0.0.0.0') {
|
||||
throw new Error(`cloudEnv.get: expected value 0.0.0.0, but actually received value ${cloudEnv.get('IP', '0.0.0.0')}`);
|
||||
}
|
||||
|
||||
if (!(cloudEnv.defaults instanceof Object)) {
|
||||
throw new Error(`cloudEnv.defaults: expected value of defaults be an instance of Object, but it was actually an instance of another class: ${typeof cloudEnv.defaults}`);
|
||||
}
|
||||
51
types/cloud-env/index.d.ts
vendored
Normal file
51
types/cloud-env/index.d.ts
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
// Type definitions for cloud-env 0.2.2
|
||||
// Project: https://github.com/ryanj/cloud-env
|
||||
// Definitions by: Ben Davies <https://github.com/Morfent>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare interface DefaultSettings {
|
||||
PORT?: number;
|
||||
IP?: string;
|
||||
HOSTNAME?: string;
|
||||
APP_NAME?: string;
|
||||
MONGODB_DB_URL?: string;
|
||||
MONGODB_DB_HOST?: string;
|
||||
MONGODB_DB_PORT?: number;
|
||||
MONGODB_DB_USERNAME?: string;
|
||||
MONGODB_DB_PASSWORD?: string;
|
||||
POSTGRESQL_DB_URL?: string;
|
||||
POSTGRESQL_DB_HOST?: string;
|
||||
POSTGRESQL_DB_PORT?: number;
|
||||
POSTGRESQL_DB_USERNAME?: string;
|
||||
POSTGRESQL_DB_PASSWORD?: string;
|
||||
MYSQL_DB_URL?: string;
|
||||
MYSQL_DB_HOST?: string;
|
||||
MYSQL_DB_PORT?: number;
|
||||
MYSQL_DB_USERNAME?: string;
|
||||
MYSQL_DB_PASSWORD?: string;
|
||||
}
|
||||
|
||||
declare type MaybeNum = number | void;
|
||||
declare type MaybeStr = string | void;
|
||||
|
||||
export const get: (key: string, default_key?: string) => MaybeStr;
|
||||
export const defaults: { [key: string]: DefaultSettings; };
|
||||
export const PORT: MaybeNum;
|
||||
export const IP: MaybeStr;
|
||||
export const HOSTNAME: MaybeStr;
|
||||
export const APP_NAME: MaybeStr;
|
||||
export const MONGODB_DB_URL: MaybeStr;
|
||||
export const MONGODB_DB_HOST: MaybeStr;
|
||||
export const MONGODB_DB_PORT: MaybeNum;
|
||||
export const MONGODB_DB_USERNAME: MaybeStr;
|
||||
export const MONGODB_DB_PASSWORD: MaybeStr;
|
||||
export const POSTGRESQL_DB_URL: MaybeStr;
|
||||
export const POSTGRESQL_DB_HOST: MaybeStr;
|
||||
export const POSTGRESQL_DB_PORT: MaybeNum;
|
||||
export const POSTGRESQL_DB_USERNAME: MaybeStr;
|
||||
export const POSTGRESQL_DB_PASSWORD: MaybeStr;
|
||||
export const MYSQL_DB_URL: MaybeStr;
|
||||
export const MYSQL_DB_HOST: MaybeStr;
|
||||
export const MYSQL_DB_PORT: MaybeNum;
|
||||
export const MYSQL_DB_USERNAME: MaybeStr;
|
||||
export const MYSQL_DB_PASSWORD: MaybeStr;
|
||||
19
types/cloud-env/tsconfig.json
Normal file
19
types/cloud-env/tsconfig.json
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"lib": ["es6"],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": ["../"],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"cloud-env-tests.ts"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user