1.0.0 • Published 3 years ago

@nebhale/client-nodejs v1.0.0

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
3 years ago

client-nodejs

Tests codecov

client-nodejs is a library to access Service Binding Specification for Kubernetes conformant Service Binding Workload Projections.

Example

import * as Bindings from 'bindings'
import { Pool } from 'pg'

async function main() {
    let b = await Bindings.fromServiceBindingRoot()
    b = await Bindings.filter(b, 'postgresql')
    if (b == undefined || b.length != 1) {
        throw Error(`Incorrect number of PostgreSQL drivers: ${b == undefined ? "0" : b.length}`)
    }

    const u = await Bindings.get(b[0], 'url')
    if (u == undefined) {
        throw Error('No URL in binding')
    }

    const conn = new Pool({connectionString: u})

    // ...
}

License

Apache License v2.0: see LICENSE for details.