node2mysql

0.0.1 • Public • Published

wss2mysql gateway

This is a simple secure webscoket to mysql gateway.

Use to run stored procedures from a secure weboskcet client on mysql.

For security reasons, only procedures are allowed.

See the source on index.js, the index.js has a complete example for a client and server implementation.

How to Test

Fist, set all ENV vars before runing the index.js Example:

#!/bin/bash 
export WEBSOCKET_CLIENT_HOST = 'localhost';
export WEBSOCKET_PROTOCOL = 'ws2mysql-protocol';
export WEBSOCKET_PORT = 3001;
export WEBSOCKET_CERT_FILE = '/etc/ssl/certs/ssl-cert-snakeoil.pem';
export WEBSOCKET_CERT_KEY = '/etc/ssl/private/ssl-cert-snakeoil.key';
export WEBSOCKET_CERT_CA = '';
export MYSQL_HOST = 'localhost';
export MYSQL_USER = 'root';
export MYSQL_PASSWORD = '';
export MYSQL_DB = 'test';
export MYSQL_PORT = '3306';
nodejs ./index.js

How to run from a websocket client:

Just send the following message via websocket to this server:

const message = '{"proc":"PROCEDURE_NAME","callback":"ON_MYSQL_DATA","args":["user@example.com","PASS"]}';

The server will respond to websocket client with with:

const respons = '{"proc":"PROCEDURE_NAME","callback":"ON_MYSQL_DATA","args":[{"id":2,"name":"test","email":"user@example.com","pass":"test"}]}';

Dependencies (5)

Dev Dependencies (0)

    Package Sidebar

    Install

    npm i node2mysql

    Weekly Downloads

    0

    Version

    0.0.1

    License

    ISC

    Last publish

    Collaborators

    • wendelmaques