1 Star 0 Fork 1

K. / app-env-conf.js

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

app-env-conf.js

项目介绍

node.js 应用程序环境配置管理类

安装教程

npm install app-env-conf --save

yarn add app-env-conf

使用说明

推荐在实际的项目中,添加一个 config.js,输出当前项目的 AppConf 唯一实例,而不要在源代码中创建多个 new AppConf() 实例来使用。

// src/config.js

import AppConf from 'app-env-conf';

const appConf = new AppConf();

export default appConf.config;

抑或对 AppConf 部分属性和方法进行重载

// src/config.js

import AppConf from 'app-env-conf';

class YourAppConf extends AppConf {
	envFile = '.env';

	getConfigFiles() {
		return [
			/* ... 特定的项目配置环境路径组 */
		];
	}
}

const appConf = new YourAppConf();

export default appConf.config;

在其他的 module 中加载 config.js

// src/others.js

import config from './config';

appConf.config 属性实际上为 AppConf 实例的 getter 方法,主要用于延迟实际加载配置的时机。

The MIT License (MIT) Copyright (c) 2018 曾建凯 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.

简介

node.js应用程序环境配置管理类 展开 收起
NodeJS
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
NodeJS
1
https://gitee.com/janpoem/app-env-conf.js.git
git@gitee.com:janpoem/app-env-conf.js.git
janpoem
app-env-conf.js
app-env-conf.js
master

搜索帮助