@adpt/cloud
Version:
AdaptJS cloud component library
64 lines • 1.87 kB
JavaScript
;
/*
* Copyright 2019 Unbounded Systems, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const core_1 = require("@adpt/core");
const lodash_1 = tslib_1.__importDefault(require("lodash"));
function notUndefined(x) {
return x !== undefined;
}
/**
* Component that represents an external provider of a Postgres database
*
* @remarks
*
* See {@link postgres.PostgresProviderProps}.
*
* Use this component to connect other cloud components to a external
* Postgres services, such as Google CloudSQL or Amazon RDS.
*
* @example
*
* ```
* const pg = handle();
*
* <PostgresProvider handle={pg}
* hostname="mypostgres.com:5432"
* db="db"
* user="myuser"
* password={process.env.PGPASSWORD}
* />
*
* <NodeService src="/somedir" connectTo={pg} />
* ```
*
* @public
*/
function PostgresProvider(props) {
core_1.useImperativeMethods(() => ({
connectEnv: () => lodash_1.default.pickBy({
PGHOST: props.host,
PGDATABASE: props.database,
PGUSER: props.user,
PGPASSWORD: props.password
}, notUndefined)
}));
return null;
}
exports.PostgresProvider = PostgresProvider;
exports.default = PostgresProvider;
//# sourceMappingURL=PostgresProvider.js.map