@kwaeri/database-driver
TypeScript icon, indicating that this package has built-in type declarations

0.5.1 • Public • Published

Patreon kwaeri-node-kit-database-driver PayPal

A Massively Modified Open Source Project by kirvedx

GPG/Keybase Google GitLab GitHub npm

The @kwaeri/database-driver component for the @kwaeri/node-kit application platform

pipeline status coverage report CII Best Practices

TOC

The Implementation

@kwaeri/database-driver reinvents the database-driver portion of the kwaeri platform.

As the database-driver component was originally baked into the nk module, its usage was entirely controlled by it. As we discern the process for decoupling the individual components which make up a kwaeri application, we'll begin to simplify the act of doing so, and provide documentation for utilizing each component individually.

Getting Started

@kwaeri/node-kit wraps the various components under the kwaeri scope necessary for building a kwaeri application, and provides a single entry point for easing the process of building a kwaeri application.

@kwaeri/cli wraps the various CLI components under the @kwaeri scope, and provides a single entry point to the user executable framework.

However, if you wish to install @kwaeri/database-driver and utilize it specifically - perform the following steps to get started:

Installation

Install @kwaeri/database-driver:

npm install @kwaeri/database-driver

Include the Component Module

To leverage the database database-driver, you'll first need to include it:

// INCLUDES
import {
  DatabaseConnectionBits,
  DatabaseDriver,
  QueryResult
} from '@kwaeri/database-driver';

Extend the Class

As DatabaseDriver is an abstract class, an instance of it may not be created. Instead, and as a minimum requirement, you'll need to extend it.

You'll need to define a constructor which takes a configuration of type DriverConnectionBits, and pass the configuration in a call to super(). You'll also need to define the query method, as it too is an abstract implementation - used to mandate its presence in a DatabaseDriver instance, while also allowing its implementation to be controlled by the developer.

Here's the process simplified:

class DerivedDriver extends BaseDriver {

  constructor( config: DriverConnectionBits ) {
    super( config );
  }

  query<T extends QueryResult>( query: string ): Promise<T> {

    // Implement query here
    [rows, fields] = ( query ) ? [ query, query ] : [ query, query ];

    // Obviously correct the above to resolve - its the setup for mysql2

    return Promise.resolve( { rows, fields } );
  }
};

Provide a configuration

In order to instantiate an extended database-driver object, you'll need to provide a configuration of type DriverConnectionBits:

const connectionBits: DriverConnectionBits = { host: "fake", port: 5000, database: "nonexistent", user: "not_real", password: "empty" };

Use the extended database-driver object

To use the extended database-driver object, you must supply the database-driver constructor with the configuration you created earlier:

const dbo = new DerivedDriver( connectionBits );

Usage

The intended usage of the @kwaeri/database-driver component module is as an abstract class, also defining the standard interface for database driver providers, for database driver providers to extend from.

A fuller example with query()

Combining the previous section(s), and leveraging the provided query() method of our extended class:

const dbo = new
    connectionBits: DriverConnectionBits = { host: "fake", port: 5000, database: "nonexistent", user: "not_real", password: "empty" },
    dbo = new Derived( connectionBits );

try {
    const result = await dbo.query( "" );
}
catch( error ) {
    return Promise.reject( new Error( `There was an error: '${error}'` ) );
}

NOTE

More documentation to come!

How to Contribute Code

Our Open Source projects are always open to contribution. If you'd like to cocntribute, all we ask is that you follow the guidelines for contributions, which can be found at the Massively Modified Wiki

There you'll find topics such as the guidelines for contributions; step-by-step walk-throughs for getting set up, Coding Standards, CSS Naming Conventions, and more.

The project also leverages Keybase for communication and alerts - outside of standard email. To join our keybase chat, run the following from terminal (assuming you have keybase installed and running):

keybase team request-access kwaeri

Alternatively, you could search for the team in the GUI application and request access from there.

Other Ways to Contribute

There are other ways to contribute to the project other than with code. Consider testing the software, or in case you've found an Bug - please report it. You can also support the project monetarly through donations via PayPal.

Regardless of how you'd like to contribute, you can also find in-depth information for how to do so at the Massively Modified Wiki

Bug Reports

To submit bug reports, request enhancements, and/or new features - please make use of the issues system baked-in to our source control project space at Gitlab

You may optionally start an issue, track, and manage it via email by sending an email to our project's support desk.

For more in-depth documentation on the process of submitting bug reports, please visit the Massively Modified Wiki on Bug Reports

Vulnerability Reports

Our Vulnerability Reporting process is very similar to Gitlab's. In fact, you could say its a fork.

To submit vulnerability reports, please email our Security Group. We will try to acknowledge receipt of said vulnerability by the next business day, and to also provide regular updates about our progress. If you are curious about the status of your report feel free to email us again. If you wish to encrypt your disclosure email, like with gitlab - please email us to ask for our GPG Key.

Please refrain from requesting compensation for reporting vulnerabilities. We will publicly acknowledge your responsible disclosure, if you request us to do so. We will also try to make the confidential issue public after the vulnerability is announced.

You are not allowed, and will not be able, to search for vulnerabilities on Gitlab.com. As our software is open source, you may download a copy of the source and test against that.

Confidential Issues

When a vulnerability is discovered, we create a [confidential issue] to track it internally. Security patches will be pushed to private branches and eventually merged into a security branch. Security issues that are not vulnerabilites can be seen on our public issue tracker.

For more in-depth information regarding vulnerability reports, confidentiality, and our practices; Please visit the Massively Modified Wiki on Vulnerability

Donations

If you cannot contribute time or energy to neither the code base, documentation, nor community support; please consider making a monetary contribution which is extremely useful for maintaining the Massively Modified network and all the goodies offered free to the public.

Donate via PayPal.com

Package Sidebar

Install

npm i @kwaeri/database-driver

Weekly Downloads

0

Version

0.5.1

License

(Apache-2.0 WITH LLVM-exception OR MIT)

Unpacked Size

76.6 kB

Total Files

15

Last publish

Collaborators

  • rik