open-index/open-npm huggingface dataset:
npm package: @knetik/knetikcloud-env-init
Description: Data is defined one request per json file.
Latest version: 3.1.45


## DATA DEFINITIONS

Data is defined one request per json file.

```
{
  // https://github.com/knetikmedia/knetikcloud-javascript-client
  
  // knetikcloud client class
  "class_name": "BRERuleEngineRulesApi", 
  
  // knetikcloud client create and update methods
  "save_method": "createBRERule",
  "update_method": "updateBRERule",
  
  // objects that should be processed before this file
  "depends_on": ["triggers/notifications/send_to_email.json"],

  // Create method params signature as defined at https://integration.knetikcloud.com/api.html
  // Optional. If not provided, method params are dynamically extracted.
  "save_params": [ "opts" ]
  
  // Update method params signature as defined at https://integration.knetikcloud.com/api.html
  // Optional. If not provided, method params are dynamically extracted.
  "update_params": [ "id", "opts" ]
  
  // Methods arguments. Provide values to methods params.
  "args": [
    { "id": 1, "opts": {} }
  ]
}
```

## CONFIG VALUES PER ENVIRONMENT

Some object elements may change for each env (dev, stage, prod). When this is
the case, create a config.json file and add your environment specific variables
there. When the file is processed Mustache is used to replace dynamic elements
inside the module's `opts` array with matching values from the config.json file.

Keep in mind, the json object definition file must still be valid json. 

```
./config.json

{
  "jsapi_app_id": "thermo-dev"
}

./data/configs/jsapi_app_id.json

{
  "class_name": "ConfigsApi",
  "method": "createConfig",
  "depends_on": [],
  "opts": [{ "config": {
    "name":"jsapi_app_id",
    "value":"{{jsapi_app_id}}",
    "public_read":false
  }}]
}

// resutling in

{
  "class_name": "ConfigsApi",
  "method": "createConfig",
  "depends_on": [],
  "opts": [{ "config": {
    "name":"jsapi_app_id",
    "value":"thermo-dev",
    "public_read":false
  }}]
}

```

## TESTING DATA OBJECTS

Print all data objects to the console for review

```
knetikcloud-init test
```

Print a single data object to the console for review

```
knetikcloud-init test -p <path to object json file>
```

## IN APP USAGE

```
const Builder = require('knetikcloud-env-init')
const builder = new Builder({
  app_id: 'knetikcloud_app_id',
  token: 'knetikcloud_admin_token',
  data_dir: 'relative path to your data root' // optional
  config_path: 'relative path to your config.json file' // optional
  configs: 'valid json object for dynamic variable replacement' // optional
})

builder.result()
```

## CLI

#### Install

```
npm install -g knetikmedia/knetikcloud-init-client
```

#### Usage

```
knetikcloud-init help
```
npm package: @knetik/micro-auth
Description: This package adds a jwt token authorization and express middleware as a Micro Core Adaptor allowing your [micro-core](https://www.npmjs.com/package/@knetik/micro-core) application to  define an authentication strategy
Latest version: 3.0.17

# Knetik Micro Auth

This package adds a jwt token authorization and express middleware as a Micro
Core Adaptor allowing your
[micro-core](https://www.npmjs.com/package/@knetik/micro-core) application to 
define an authentication strategy

### Install

```
$ npm install @knetik/micro-auth
```

Then add the ADAPTORS config to your `config/environments/*.json` files

```
"ADAPTORS": [ '@knetik/micro-auth' ]
```
npm package: @knetik/micro-clustermanager
Description: This package allows config variables to be loaded from clustermanager config json when using [micro-core](https://www.npmjs.com/package/@knetik/micro-core) the multi tenant framework.
Latest version: 3.1.45

# Knetik Micro Clustermanager

This package allows config variables to be loaded from clustermanager config 
json when using [micro-core](https://www.npmjs.com/package/@knetik/micro-core) 
the multi tenant framework.

Replace the values of your config variables with clustmernanager property key
paths. 

## Customer Index Resolution

Dynamic customer resolution using a simple path convention.

The adaptor loops through each name index looking for the matching app_id. On 
matching customer, the index is extracted and used for configuration value 
resolution.

#### Setup clustermanager access

```
// config/env.json

{
  "CONNECTION_CONFIG_STRATEGY": "clustermanager",
  "CONNECTION_CONFIG_IDENTIFIER": "customers.configurations[].name",
  "CLUSTER_MANAGER_URL": "https://clustermanager...",
  "CLUSTER_MANAGER_USER": "...",
  "CLUSTER_MANAGER_PASS": "...",
}
```

#### Configure your application

Add the clustermanager config keys as values to your adaptor config vars

```
{
  "MONGOOSE_USERNAME": "customers.configurations[].database.mongo.username",
  "MONGOOSE_PASSWORD": "customers.configurations[].database.mongo.password",
  "MONGOOSE_URL": "customers.configurations[].database.mongo.servers",
  "MONGOOSE_DB": "customers.configurations[].database.mongo.dbName",
  "MONGOOSE_OPTIONS": "customers.configurations[].database.mongo.options",
}
```

The adaptor will detect a clustermanager path value and use the resolved
customer index to apply the correct clustermanager config value to the
micro-core config property.

```
customers.configurations[0].name: "customer1"
customers.configurations[0].database.mongo.dbName
```

Now your mongo db adaptor will use the clustermanager config data for db
connection info.

Any unresolved clustermanager keys will fallback to process.env
npm package: @knetik/micro-credentials_store-s3
Description: This package provides a simple key value store using amazon aws' s3 service to the [micro-core](https://www.npmjs.com/package/@knetik/micro-core) multi tenant framework.
Latest version: 3.1.45

# Knetik Micro Credentials Store: S3

This package provides a simple key value store using amazon aws' s3 service to
the [micro-core](https://www.npmjs.com/package/@knetik/micro-core) multi
tenant framework.

## Setup the Credentials Store

```
// config/environments/env.json

{
  "CREDENTIALS_STORAGE_PROVIDER": "s3",
  "S3_CREDENTIALS_STORE_BUCKET": "micro-credentials-store",
  "AWS_PROFILE": "...",
}
```

2 contextualized stores are made available.

- Core.CredentialsStore
- App.CredentialsStore

## Methods

On init the Core object will be assigned a credential store instance exposing three
functions `get, set, remove`

```
Core.CredentialsStore.set('token', '123123').then(token => token);
Core.CredentialsStore.get('token').then(token => token /* 123123 */);
Core.CredentialsStore.remove('token');
```

On Core connect, the returned App instance will also be assigned a store 
instance but scoped to the app_id

```
App.CredentialsStore.set('token', '321321').then(token => token);
App.CredentialsStore.get('token').then(token => token /* 321321 */);
App.CredentialsStore.remove('token');
```
npm package: @knetik/micro-es
Description: This package adds an elasticsearch client to any [micro-core](https://www.npmjs.com/package/@knetik/micro-core) application as a multi tenant adaptor
Latest version: 3.1.45

# Knetik Micro ES

This package adds an elasticsearch client to any
[micro-core](https://www.npmjs.com/package/@knetik/micro-core) application
as a multi tenant adaptor

When a customer connects to a micro-core application, the required app_id
is passed into the elsaticsearch initializer and used as a filter on searches. 
Then creating a connection and loading any es models defined in the models 
directory.
npm package: @knetik/micro-express
Description: This package adds the an express http server to any [micro-core](https://www.npmjs.com/package/@knetik/micro-core) application as a Core Adaptor
Latest version: 3.1.45

# Knetik Micro Express

This package adds the an express http server to any
[micro-core](https://www.npmjs.com/package/@knetik/micro-core) application
as a Core Adaptor

### Install

```
$ npm install @knetik/micro-express
```

Then add the CORE_ADAPTORS config to your `config/environments/*.json` files

```
"CORE_ADAPTORS": [ '@knetik/micro-express' ]
```

### Express

Sets up an http web server built with Express and Run when calling
`Core.serve(app_root_path)`. Routes are stored in `app/routes` and should be
wrapped in a function with a single `Server` parameter.

Multi tenancy is handled on a per request basis using an express middleware.
`Core.connect(app_id, bearer_token)` is called internally returning an app 
instance scoped to the client and attaching it to the `request` object. 
Access to the App instance is demonstrated in the example route.

- [example](./src/example.route.js)

Multi tenant resolution is keys on the requesting app_id. The `app_id` is 
resolved from the first sub domain segment of the requesting domain or from the 
configured `APP_ID_KEY` request header. Which defaults to `x-knetikcloud-appid`

### Service Auto Load

Set the `AUTO_LOAD_SERVICE_ROUTES` env var to true. This will load the modules
inside `app/services` as routes and apply a default route to each service.
Config options are available for a auto loaded service. Refer to the
[DOCS](./DOCS.md) for more info on how to configure auto loaded service routes

Navigate to `/routes` for a list of the auto loaded routes. If the
`AUTO_LOAD_SERVICE_ROUTES` var is not set, this route will not be available.

### Swagger

Swagger json and swagger ui are supported through jsdoc parsing and an express
static route.

- use swagger yaml syntax in a doc block - https://github.com/knetikmedia/micro-core/blob/master/app/routes/example.js#L3-L28
- view the auto generated swagger.json file - /swagger.json
- render the swagger ui - /swagger-ui
npm package: @knetik/micro-knetikcloud
Description: This package adds a customer scoped instance of the javascript knetikcloud sdk to [micro-core](https://www.npmjs.com/package/@knetik/micro-core) the multi tenant framework.
Latest version: 3.1.45

# Knetik Micro KnetikCloud

This package adds a customer scoped instance of the javascript knetikcloud sdk
to [micro-core](https://www.npmjs.com/package/@knetik/micro-core) the multi 
tenant framework.

When a customer connects to a micro-core application, the required app_id and optional
access token are passed into the knetikcloud sdk. Creating an sdk instance
scoped to this this customer.

In `micro-console`

```
App.connect(app_id, access_token)
.then(App => App.KnetikCloud.get('ContentArticlesApi'))
.then(api => api.getArticles())
.then(res => console.log(res))
.catch(err => console.log(err))
```

In a `micro-core` module

```
module.exports (App) => {
  App.KnetikCloud.get('ContentArticlesApi')
}
```

In a `micro-core` express route

```
Server.get('/articles', (req, res) => {
  const api = req.App.Knetikcloud.get('ContentArticlesApi');

  api.getArticles(req.query)
  .then(result => res.json({ resp: result }))
  .catch(err => res.status(422).json({ err }));
});
```
npm package: @knetik/micro-lib
Description: This package provides some reusable micro-core modules that will come in handy for any [micro-core](https://www.npmjs.com/package/@knetik/micro-core) application.
Latest version: 3.1.45

# Knetik Micro Lib

This package provides some reusable micro-core modules that will come in handy
for any [micro-core](https://www.npmjs.com/package/@knetik/micro-core) 
application.
npm package: @knetik/micro-mongo
Description: This package add the mongoose mongodb client to any [micro-core](https://www.npmjs.com/package/@knetik/micro-core) application as a multi tenant adaptor
Latest version: 3.1.45

# Knetik Micro Mongoose

This package add the mongoose mongodb client to any
[micro-core](https://www.npmjs.com/package/@knetik/micro-core) application
as a multi tenant adaptor

When a customer connects to a micro-core application, the required app_id
is passed into the mongoose initializer and used as the database name. 
Then creating a connection and loading any mongoose models defined in the models 
directory.

In `app/models/example.mongoose.js`

```
const mongoose = require('mongoose');

const ExampleSchema = new mongoose.Schema({
    'prop': { 'type': Number, 'required': true },
}, { 'strict': true });

module.exports = mongoose.model('Example', ExampleSchema);
```

In `micro-console`

```
App.connect(app_id, access_token)
.then(App => App.Mongoose.get('Exmaple'))
.then(Example => Example.create({ prop: 42 }))
.then(res => console.log(res))
.catch(err => console.log(err))
```

In a `micro-core` module

```
module.exports (App) => {
  cosnt Example = App.Mongoose.get('Exmaple')
  Example.create({ prop: 42 })
}
```
npm package: @knetik/micro-mongoose
Description: This package add the mongoose mongodb client to any [micro-core](https://www.npmjs.com/package/@knetik/micro-core) application as a multi tenant adaptor
Latest version: 3.0.17

# Knetik Micro Mongoose

This package add the mongoose mongodb client to any
[micro-core](https://www.npmjs.com/package/@knetik/micro-core) application
as a multi tenant adaptor

When a customer connects to a micro-core application, the required app_id
is passed into the mongoose initializer and used as the database name. 
Then creating a connection and loading any mongoose models defined in the models 
directory.

In `app/models/example.mongoose.js`

```
const mongoose = require('mongoose');

const ExampleSchema = new mongoose.Schema({
    'prop': { 'type': Number, 'required': true },
}, { 'strict': true });

module.exports = mongoose.model('Example', ExampleSchema);
```

In `micro-console`

```
App.connect(app_id, access_token)
.then(App => App.Mongoose.get('Exmaple'))
.then(Example => Example.create({ prop: 42 }))
.then(res => console.log(res))
.catch(err => console.log(err))
```

In a `micro-core` module

```
module.exports (App) => {
  cosnt Example = App.Mongoose.get('Exmaple')
  Example.create({ prop: 42 })
}
```
npm package: @knetik/micro-postgres
Description: This package adds postgres support using sequelize to any [micro-core](https://www.npmjs.com/package/@knetik/micro-core) application as a multi tenant adaptor.
Latest version: 3.0.17

# Knetik Micro Postgres

This package adds postgres support using sequelize to any
[micro-core](https://www.npmjs.com/package/@knetik/micro-core) application
as a multi tenant adaptor.

When a customer connects to a micro-core application, the required app_id
is passed into the postgres initializer and used as the database name.
Then creating a connection and loading any sequelize models defined in the models 
directory.

## Example Usage

In `app/models/example.postgres.js`

```
const Sequelize = require('sequelize');

module.exports = (sequelize) => {
  return sequelize.define('example', {
    prop: {
      type: Sequelize.NUMBER
    }
  },
  {
    timestamps  : true,
    underscored : true
  });
}
```

In `micro-console`

```
App.connect(app_id, access_token)
.then(App => App.Postgres.get('Example'))
.then(Example => Example.create({ prop: 42 }))
.then(res => console.log(res))
.catch(err => console.log(err))
```

In a `micro-core` module

```
module.exports (App) => {
  cosnt Example = App.Postgres.get('Exmaple')
  Example.create({ prop: 42 })
}
```

### Migrations

Migrations are handled with umzug: https://github.com/sequelize/umzug

1. Add migrations to `APP_ROOT/db/migrations`
2. Migration status will be checked on each request.
3. If there are pending migrations, they will be run and then the status will
   be cached in the mc_internal_metadata table per client.

Feel free to add migration hook into your deploy tooling.
npm package: @knetik/micro-queue
Description: This package adds redis queue support using Bull Queue to any [micro-core](https://www.npmjs.com/package/@knetik/micro-core) application as a multi tenant adaptor.
Latest version: 3.1.45

# Knetik Micro Queue

This package adds redis queue support using Bull Queue to any
[micro-core](https://www.npmjs.com/package/@knetik/micro-core) application
as a multi tenant adaptor.

When a customer connects to a micro-core application, the required app_id
is passed into the adaptor initializer and used as the context for any jobs
created using the micro queue Job class interface.

### Setup

Install the `@knetik/micro-queue` package

```
yarn add @knetik/micro-queue
```

Add the Adaptor to your config/environments/{env}.json

```
"ADAPTORS": [
  "@knetik/micro-queue"
]
```

Add the `REDIS_HOST` param as well

```
"REDIS_HOST": "127.0.0.1"
```

## Job Generator

```
$ yarn run micro-queue generate {job_name}
```

A file is generated in `app/jobs/{job_name}.job.js`

if the `{job_name}` id `some_long_process`, the contents of `app/jobs/{job_name}.job.js` are:

```
const { JobBase } = require('@knetik/micro-queue');

module.exports = class SomeLongProcessJob extends JobBase {
  static perform(App, params, progress) {
    App.Logger.info('performing SomeLongProcessJob');

    /* ====== EXAMPLE USAGE ========= */
    App.Logger.info('SomeLongProcessJob', params);

    let pending = 100;
    let total = 0;

    // Jobs must return a Promise
    return new Promise((resolve, reject) => {
      const interval = setInterval(() => {
        pending -= 1;
        total += 1;

        App.Logger.info('SomeLongProcessJob progress', pending);

        // use progress to increment the jobs progress status
        progress(total);

        if (!pending) {
          resolve('done');
          clearInterval(interval);
        }
      }, 1000);
    });
    /* ====== END EXAMPLE USAGE ========= */
  }
};

// Set the max concurrency value for this job.
module.exports.concurrency = 50;
```

### Usage

The Adaptor is added to the Micro Core application at `App.Queue`. Use
`App.Queue#get` to load job classes form the App's initialized jobs.

```
const Job = App.Queue.get('SomeLongProcessJob');
```

Call `perform_later` on the Job class passing in the job data and the job
options

```
const data = { hi: 'there' };
const options = {};

Job.perform_later(data, options);
```

### Queue UI

if the Micro Express Adaptor is installed the Queue management UI is mounted at
`/arena`. Visit it in the browser for handy job management.

### Documentation

More info is available in the [DOCS](./DOCS.md)
npm package: @knetik/micro-redis
Description: This package adds redis support using IORedis to any [micro-core](https://www.npmjs.com/package/@knetik/micro-core) application as a multi tenant adaptor.
Latest version: 3.1.45

# Knetik Micro Redis Adaptor

This package adds redis support using IORedis to any
[micro-core](https://www.npmjs.com/package/@knetik/micro-core) application
as a multi tenant adaptor.

When a customer connects to a micro-core application, the required app_id
is passed into the adaptor initializer and used as the context for any redis
records managed using the adaptor.

### Setup

Install the `@knetik/micro-redis` package

```
yarn add @knetik/micro-redis
```

Add the Adaptor to your config/environments/{env}.json

```
"ADAPTORS": [
  "@knetik/micro-redis"
]
```

Add the `REDIS_HOST` param as well

```
"REDIS_HOST": "127.0.0.1"
```

### Documentation

More info is available in the [DOCS](./DOCS.md)
npm package: @knetik/micro-sql
Description: This package adds the objection sql client to any [micro-core](https://www.npmjs.com/package/@knetik/micro-core) application as a multi tenant adaptor.
Latest version: 3.1.45

# Knetik Micro Sql

This package adds the objection sql client to any
[micro-core](https://www.npmjs.com/package/@knetik/micro-core) application
as a multi tenant adaptor.

When a customer connects to a micro-core application, the required app_id
is passed into the sql initializer and used for multi tenancy support. 

### Setup

Install the `@knetik/micro-sql` package

```
yarn add @knetik/micro-sql
```

Add the Adaptor to your config/environments/{env}.json/js

```
"ADAPTORS": [
  "@knetik/micro-sql"
]
```

Add the `SQL` configs as well

```
SQL_CLIENT: string,
SQL_HOST: string,
SQL_USER: string,
SQL_PASS: string,
SQL_PORT: string,
SQL_DB: string,
SQL_SSL: string
```

### Documentation

More info is available in the [DOCS](./DOCS.md)
npm package: @knfs-tech/alb
Description: This package implements a simple application load balancer (ALB) using Node.js's `cluster` module. It helps distribute incoming requests across multiple worker processes while maintaining configurable settings for minimum, maximum, and idle time for worke
Author: Kent Phung
Latest version: 1.1.1


<h1> <span style="color:#013C4D;">About</span> <span style="color:#2B7F84;">Knfs ALB</span></h1>
<a href="https://img.shields.io/github/license/knfs-library/alb" alt="License">
	<img src="https://img.shields.io/github/license/knfs-library/alb" alt="License" />
</a>
<a href="https://img.shields.io/github/contributos/knfs-library/alb" alt="License">
	<img src="https://img.shields.io/github/contributors/knfs-library/alb" alt="License" />
</a>
<a href="https://img.shields.io/github/languages/code-size/knfs-library/alb" alt="License">
	<img src="https://img.shields.io/github/languages/code-size/knfs-library/alb" alt="License" />
</a>

### A simple application load balancer (ALB) for Node.js

This package implements a simple application load balancer (ALB) using Node.js's `cluster` module. It helps distribute incoming requests across multiple worker processes while maintaining configurable settings for minimum, maximum, and idle time for workers. This is ideal for scaling applications on multi-core systems.

---

## Install

To install the package, use either `npm` or `yarn`:

```bash
npm i @knfs-tech/alb
# or
yarn add @knfs-tech/alb
```

## Usage
You can integrate the ALB into your Node.js app by following the example below:

```javascript
const express = require("express");
const app = express();

const alb = require("@knfs-tech/alb");
const port = 3000;

// Define a simple route
app.get('/', (req, res) => {
  process.send({ type: 'request_handled' });
  console.log(`${process.pid}`);
  res.send(`Handled by worker ${process.pid}`);
});

// Run the app
const runApp = () => {
  app.listen(port, () => {
    console.log("App is running on port 3000");
  });
};

// Start the ALB with your app and configuration
alb(runApp, {
  max: 4, // Maximum number of worker processes
  min: 2  // Minimum number of worker processes
});
```

This code sets up a load balancer with the specified configurations. The alb module will manage the worker processes and ensure that the application is efficiently scaled across multiple CPU cores.

## Configuration
You can customize the following options in the configuration object:

- **max**: Maximum number of worker processes (default: number of CPU cores available).
- **min**: Minimum number of worker processes to maintain (default: 2).
- **idleTime**: Maximum idle time (in milliseconds) for a worker before it is terminated (default: 30,000ms).
- **log**: <boolean> Log when run

## Author
* [Kent Phung](https://github.com/khapu2906)
  
## Owner
* [Knfs.,jsc](https://github.com/knfs-library)

## More

## License

Bamimi is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
npm package: @knfs-tech/bamimi-socket.io
Description: Simplify socket usage
Author: Kent Phung
Latest version: 1.1.1

<p align="center">
  <img width="250" src="https://github.com/knfs-jsc/bamimi-socket.io/blob/master/docs/images/logo-background.png?raw=true">
  <br>
	<a href="https://app.fossa.com/projects/git%2Bgithub.com%2Fknfs-jsc%2Fbamimi-socket.io?ref=badge_shield&issueType=license" alt="FOSSA Status"><img src="https://app.fossa.com/api/projects/git%2Bgithub.com%2Fknfs-jsc%2Fbamimi-socket.io.svg?type=shield&issueType=license"/></a>
	<a href="https://app.fossa.com/projects/git%2Bgithub.com%2Fknfs-jsc%2Fbamimi-socket.io?ref=badge_shield&issueType=security" alt="FOSSA Status"><img src="https://app.fossa.com/api/projects/git%2Bgithub.com%2Fknfs-jsc%2Fbamimi-socket.io.svg?type=shield&issueType=security"/></a>
	<img src="https://scrutinizer-ci.com/g/knfs-jsc/bamimi-socket.io/badges/build.png?b=master" alt="Build Status" />
</p>

<h1> <span style="color:#013C4D;">About</span> <span style="color:#2B7F84;">Bamimi socket.io</span></h1>


This package was developed to make using sockets easier because:
 * Using router-like implementation in Express makes it easy for you to develop
 * Can write functions as functions or divide into Controllers / Services
 
---

## Install
```bash
npm i @knfs-tech/bamimi-socket.io
#or
yarn add @knfs-tech/bamimi-socket.io
```

## Usage

**Step 1**: Create file *config.js*
```js
module.exports = {
   cors: {
   	origin: "*",
   	transports: ['websocket', 'polling'],
   },
   transports: ['websocket', 'polling'],
   ...
};

```

*Note: You can see more information at* [socket.io](https://socket.io/docs/v4/)

**Step 2**: Create file *index.js*
```js
const { createServer } = require('node:http');
const config = require("/path/to/your-config")
const socket = require("@knfs-tech/bamimi-socket.io")
const express = require("express");
const app = express();
const server = createServer(app);

socket.io(server, config)


const connection = (io, socket) => {
	console.log("____Connection___")
}

socket.on(
	'/abc',
	function (socket, next) {
		console.log("___Middleware 1 socket___")
		next()
	},
	function (socket, next) {
		console.log("___Middleware 2 socket___")
		next()
	},
	function (socket, next) {
		console.log("___Middleware 3 socket___-")
		next()
	},
	connection
)

server.listen(3001, () => {
	console.log(`server running at http://localhost:3001`);
})
```
**Step 3**: Run file *index.js*
```bash
npm start
#or
node index.js
#or
yarn start
```

## Author
* [Kent Phung](https://github.com/khapu9260)
  
## Owner
* [Knfs.,jsc](https://github.com/knfs-jsc)


## License

Bamimi is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
npm package: @knfs-tech/dsa
Description: Digital Signature Authentication module
Author: Kent Phung
Latest version: 1.0.0


<p align="center">
  <br>
	<a href="https://app.fossa.com/projects/git%2Bgithub.com%2Fknfs-jsc%2Fdsa?ref=badge_shield&issueType=license" alt="FOSSA Status"><img src="https://app.fossa.com/api/projects/git%2Bgithub.com%2Fknfs-jsc%2Fdsa.svg?type=shield&issueType=license"/></a>
	<a href="https://app.fossa.com/projects/git%2Bgithub.com%2Fknfs-jsc%2Fdsa?ref=badge_shield&issueType=security" alt="FOSSA Status"><img src="https://app.fossa.com/api/projects/git%2Bgithub.com%2Fknfs-jsc%2Fdsa.svg?type=shield&issueType=security"/></a>
	<a href="https://scrutinizer-ci.com/g/knfs-library/dsa/build-status/master"alt="scrutinizer">
	<img src="https://scrutinizer-ci.com/g/knfs-library/dsa/badges/build.png?b=master" alt="Build Status" /></a>
	<a href="https://scrutinizer-ci.com/g/knfs-library/dsa/?branch=master"alt="scrutinizer">
	<img src="https://scrutinizer-ci.com/g/knfs-library/dsa/badges/quality-score.png?b=master" alt="Scrutinizer Code Quality" /></a>
	<a href="https://github.com/knfs-library/dsa/actions"alt="scrutinizer">
	<a href="https://github.com/knfs-library/dsa/actions/workflows/unit-test.yml" alt="github">
		<img src="https://github.com/knfs-library/dsa/actions/workflows/unit-test.yml/badge.svg" alt="Github " />
	</a>
</p>


<h1> <span style="color:#013C4D;">About</span> <span style="color:#2B7F84;">Digital Signature Authentication</span></h1>

This npm package provides **Digital Signature Authentication** module for various security measures.

## Install

Install the package via npm:

```bash
npm install @knfs-tech/dsa
```

Or via yarn:

```bash
yarn add @knfs-tech/dsa
```

## Usage


```javascript
const { init, generateKeys, createSign, verifySign } = require('@knfs-tech/dsa').dsa;

// Initialize DSA configuration
init({ modulusLength: 4096, storageLocalPath: '/path/to/keys' });

// Generate public and private keys
const { publicKey, privateKey } = generateKeys('example');

// Create a digital signature
const dataToSign = 'Hello, world!';
const signature = createSign(dataToSign, privateKey);

// Verify a digital signature
const verifyData = { data: dataToSign, signature };
const isVerified = verifySign(verifyData, publicKey);

console.log('Signature verified:', isVerified);
```

## License

DSA is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).

## Author
* [Kent Phung](https://github.com/khapu2906)
  
## Owner
* [Knfs.,jsc](https://github.com/knfs-library)
npm package: @knfs-tech/eslint-plugin
Description: Eslint plugin
Author: Kent Phung
Latest version: 1.9.10

<p align="center">
  <br>
	<a href="https://github.com/knfs-library/eslint-plugin/actions"alt="github">
	<img src="https://github.com/knfs-library/eslint-plugin/actions/workflows/unit-test.yml/badge.svg" alt="Github Actions" />
	</a>
</p>

<h1> <span style="color:#013C4D;">About</span> <span style="color:#2B7F84;">ESLint Plugin</span></h1>

This npm package provides a set of custom ESLint rules to enforce code style and best practices for JavaScript projects.

## Install

Install the package via npm:

```bash
npm install --save-dev @knfs-jsc/eslint-plugin
```

Or via yarn:

```bash
yarn add --dev @knfs-jsc/eslint-plugin
```

## Usage

To use this ESLint plugin, add it to your `.eslintrc` configuration file:

```json
{
  "plugins": ["@knfs-jsc/eslint-plugin"],
  "rules": {
    "@knfs-jsc/eslint-plugin/no-arrow-functions": "error",
  }
}
```

## License

eslint-plugin is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).

## Author
* [Kent Phung](https://github.com/khapu2906)

## Owner
* [KNFs JSC](https://github.com/knfs-jsc)

---
npm package: @kngai/vue-gettext-tools
Description: Modified version of Gettext tools from eldarc/vue-gettext-tools for Vue.js to help extract strings and compile gettext files.
Author: Kevin Ngai
Latest version: 0.0.7

# vue-gettext-tools

This is a modified version of Gettext tools from eldarc/vue-gettext-tools.

# NOTE: Plugin ready for first version; Documentation is in progress.

Extract and compile gettext strings from Vue source files.
npm package: @knicola/autobind
Description: Autobind methods of a class to the instance
Author: @knicola
Latest version: 0.1.2

# @knicola/autobind

Automatically bind all methods of an object to the object itself.

## Install

Using npm:
```sh
$ npm install @knicola/autobind
```

Using yarn:
```sh
$ yarn add @knicola/autobind
```

## Usage

```ts
import { autobind } from '@knicola/autobind'

// with autobind
class Foo {
    public myname: string = 'foo'
    constructor() {
        autobind(this)
    }
    public say(): void {
        console.log(this.myname)
    }
}
const { say: sayFoo } = new Foo()
sayFoo() //=> "foo"

// without autobind
class Bar {
    public myname: string = 'bar'
    public say(): void {
        console.log(this.myname)
    }
}
const { say: sayBar } = new Bar()
sayBar() //=> [ERR]: this is undefined 
```

## License

This project is open-sourced software licensed under the [MIT license](./LICENSE).
npm package: @knicola/delay
Description: Delay code execution for a specified amount of milliseconds.
Author: @knicola
Latest version: 0.1.1

# @knicola/delay

Delay code execution for a specified amount of milliseconds. This is an [isomorphic](https://en.wikipedia.org/wiki/Isomorphic_JavaScript) variation of `require('timers/promises').setTimeout(1000)`.

## Install

Using npm:
```sh
$ npm install @knicola/delay
```

Using yarn:
```sh
$ yarn add @knicola/delay
```

## Usage

```js
import { delay, AbortError } from '@knicola/delay'

const ac = new AbortController()

// abort after 3 seconds
setTimeout(() => ac.abort(), 3000)

try {
    await delay(10e3, ac.signal)
    // work, work ..
} catch (err) {
    if (err instanceof AbortError) {
        // operation aborted ..
    }
}
```

## License

This project is open-sourced software licensed under the [MIT license](./LICENSE).
npm package: @knicola/dev-config
Description: Base configurations for typescript, eslint, typedoc and jest.
Author: @knicola
Latest version: 0.3.2

# @knicola/dev-config

Base configurations for typescript, eslint, typedoc and jest.

## Install
```sh
npm i -D @knicola/dev-config typescript eslint
```

## Setup

.eslintrc.js
```js
require('@knicola/dev-config/eslint/patch')

module.exports = {
    extends: ['./node_modules/@knicola/dev-config/eslint/node'],
    parserOptions: { tsconfigRootDir: __dirname },
    settings: {
        'import/resolver': {
            typescript: { project: __dirname },
        },
    }
}
```

tsconfig.json
```json
{
  "$schema": "https://json.schemastore.org/tsconfig",
  "extends": "@knicola/dev-config/tsconfig/node",
  "compilerOptions": {
    "types": [ "node", "jest" ],
    "paths": {
      "@/*": ["./src/*"]
    },
    "baseUrl": "."
  },
  "include": [ "**/*.ts", "**/*.js" ]
}
```

tsconfig.build.json
```json
{
  "$schema": "https://json.schemastore.org/tsconfig",
  "extends": "@knicola/dev-config/tsconfig/node",
  "compilerOptions": {
    "removeComments": true,
    "noUnusedLocals": true,
    "outDir": "lib/",
    "paths": {
      "@/*": ["./src/*"]
    },
    "baseUrl": "."
  },
  "include": [ "src/**/*.ts" ]
}
```

jest.config.ts
```ts
import { JestConfigWithTsJest } from 'ts-jest'
import jestBaseConfig from '@knicola/dev-config/jest/base'

const config: JestConfigWithTsJest = {
  ...jestBaseConfig,
  // additional config
}

export default config
```

typedoc.json
```json
{
  "$schema": "https://typedoc.org/schema.json",
  "extends": ["./node_modules/@knicola/dev-config/typedoc/base.json"],
}
```

package.json
```jsonc
{
  // ...
  "scripts": {
    "lint": "eslint src/ --ext .js,.jsx,.ts,.tsx",
    "build": "tsc -p ./tsconfig.build.json",
  }
}
```
npm package: @knicola/gh-trends
Description: Fetch trending GitHub repositories.
Author: Kyriakos Nicola
Latest version: 0.1.0

# GitHub Trends

Fetch trending GitHub repositories.

## CLI

### Installation

```sh
npm install -g @knicola/gh-trends
```

### Usage

```sh
$ gh-trends --help

GitHub Trends CLI

Usage: gh-trends [options]

Options:
    -l, --language <lang>         Programming language (default: all languages)
    -p, --period <period>         Time period: daily, weekly, or monthly (default: daily)
    -s, --spokenLanguage <code>   Spoken language code (default: all languages)
    --json                        Output in JSON format
    -h, --help                    Show this help

Examples:
    gh-trends                            # All languages, default period
    gh-trends --language javascript      # JavaScript only, default period
    gh-trends --period weekly            # All languages, weekly
    gh-trends -l python -p monthly -s en # Python, monthly, English
    gh-trends --json                     # Output in JSON format
```

## API

### Installation

```sh
npm install @knicola/gh-trends
```

### Usage

```js
import { fetchGitHubTrends } from '@knicola/gh-trends'

const repos = await fetchGitHubTrends({
  language: 'javascript',
  period: 'weekly',
  spokenLanguageCode: 'en'
})

repos.forEach(repo => {
  console.log(`${repo.author}/${repo.name}`)
  console.log(`Stars: ${repo.stars} (+${repo.newStars} this week)`)
  console.log(`Language: ${repo.language}`)
  console.log(`URL: ${repo.url}`)
})
```

## Contributing

Contributions are welcome! Please follow these steps:

1. Fork the repository.
2. Create a feature branch: `git checkout -b feature/your-feature`.
3. Make your changes and ensure tests pass.
4. Run `npm run lint:fix` and `npm run format:fix` to format code.
5. Commit your changes: `git commit -m "Add your feature"`.
6. Push to your branch: `git push origin feature/your-feature`.
7. Open a pull request.

Please ensure your code adheres to the project's style guidelines and includes appropriate documentation.

## Disclaimer

This tool scrapes public data from GitHub. Ensure compliance with GitHub's terms of service and rate limits. Use responsibly.

## License

This project is open-sourced software licensed under the [MIT license](./LICENSE).
npm package: @knicola/minibus
Description: A minibus for a node package
Author: @knicola
Latest version: 0.1.1

# @knicola/minibus

A strongly typed event emitter.

## Install

Using npm:
```sh
$ npm install @knicola/minibus
```

Using yarn:
```sh
$ yarn add @knicola/minibus
```

## Usage

```ts
import { minibus, event } from '@knicola/minibus'

// define event schema
interface IUserCreated {
    name: string
    email: string
}

// register events
const Events = {
    UserCreated: event<IUserCreated>('user:created'),
} as const

// create event bus
const bus = minibus()

// subscribe an event handler
bus.subscribe(Events.UserCreated, (data) => {
    console.log(data)
})

// dispatch a new event
bus.dispatch(Events.UserCreated, {
    name: 'Peter Pan',
    email: 'pete@neverland.com',
})
```
 
## License

This project is open-sourced software licensed under the [MIT license](./LICENSE).
npm package: @knicola/repeat
Description: Repeats the given task for a certain amount of times or forever.
Author: @knicola
Latest version: 0.1.1

# @knicola/repeat

Repeats the given task for a certain amount of times or forever.
Useful for repetative tasks, such as polling.

## Install

Using npm:
```sh
$ npm install @knicola/repeat
```

Using yarn:
```sh
$ yarn add @knicola/repeat
```

## Usage

```ts
import { repeat, RepeatOptions, RepeatTask } from '@knicola/repeat'

// default options
const options: RepeatOptions = {
    timeout: 3000,
    startOnInit: true,
    runOnStart: true,
    maxRuns: Infinity,
    maxFailures: Infinity,
}

// to be populated by the repeated task
let status: string = 'n/a'

// the task to repeat
const task: RepeatTask = async () => {
    status = await axios.get('https://example.com/api/status')
}

// initialize the repeat operation
const op = repeat(task, options)

// check if task is running
console.log(op.isRunning) //=> true

// cancel the task
op.stop()
```

## License

This project is open-sourced software licensed under the [MIT license](./LICENSE).
npm package: @knicola/retry
Description: Retries the given task a certain amount of times or until successful.
Author: @knicola
Latest version: 0.1.1

# @knicola/retry

Retries the given task a certain amount of times or until successful.
Useful for retrying tasks that might fail, such as fetching a resource.

## Install

Using npm:
```sh
$ npm install @knicola/retry
```

Using yarn:
```sh
$ yarn add @knicola/retry
```

## Usage

```ts
import { retry, RetryOptions, RetryTask } from '@knicola/retry'

// default options
const options: RetryOptions = {
    retries: 5,
    factor: 2,
    minTimeout: 1e3,
    maxTimeout: 60e3,
    randomize: true,
}

// the task to retry
const task: RetryTask = async (currentAttempt) => {
    // starting at zero, which is the immediate run
    console.log(`Attempt #${currentAttempt}`)
    await axios.get('https://example.com/api/resource')
}

// retry returns a thenable, which means that if it
// is awaited it will immediately run the task
const res = await retry(task, options)

// otherwise, it will return an instance of `Retry`
// and will wait for `run()` to start the task
const op = retry(task, options)

// start the task
const res = await op.run()
// if the `retries` limit is reached and has yet to
// succeed, it will throw the last known error..

// check if task is running
console.log(op.isRunning) //=> true

// cancel the task- this will cause
// `run()` to throw an AbortError
op.abort()
```

## License

This project is open-sourced software licensed under the [MIT license](./LICENSE).
npm package: @knicola/xbackoff
Description: JS implementation of the exponential backoff algorithm.
Author: @knicola
Latest version: 0.1.1

# @knicola/xbackoff

JS implementation of the [exponential backoff](https://en.wikipedia.org/wiki/Exponential_backoff) algorithm.

## Install

Using npm:
```sh
$ npm install @knicola/xbackoff
```

Using yarn:
```sh
$ yarn add @knicola/xbackoff
```

## Usage

### xbackoff()
Create an xbackoff function
```ts
import { xbackoff, XBackoffOptions } from '@knicola/xbackoff'

// default options
const options: XBackoffOptions = {
    factor: 2,
    minTimeout: 1e3,
    maxTimeout: 60e3,
    randomize: false,
}

const getTimeout = xbackoff(options)

getTimeout(0) //=> 1000
getTimeout(1) //=> 2000
getTimeout(2) //=> 4000
```
### compute()
Compute the timeout for the given attempt
```ts
import { compute } from '@knicola/xbackoff'

compute(0, options) //=> 1000
compute(1, options) //=> 2000
compute(2, options) //=> 4000
```

## License

This project is open-sourced software licensed under the [MIT license](./LICENSE).
npm package: @knicola/xfetch
Description: JS implementation of the XFetch algorithm.
Author: @knicola
Latest version: 0.1.1

# @knicola/xfetch

JS implementation of the [XFetch](http://cseweb.ucsd.edu/~avattani/papers/cache_stampede.pdf) probabilistic early expiration algorithm.

## Install

Using npm:
```sh
$ npm install @knicola/xfetch
```

Using yarn:
```sh
$ yarn add @knicola/xfetch
```

## Usage

### xfetch()
Wrap a function with an in-memory cache layer
```ts
import { xfetch } from '@knicola/xfetch'

const fn = async (n1: number, n2: number): Promise<number> => {
    await new Promise((resolve) => setTimeout(resolve, 3e3))
    return n1 + n2
}

const xfn = xfetch(fn, {
    key: 'cache-key',
    ttl: 30e3,
})

await xfn(1, 1)
```
Use a custom cache adapter
```ts
import { XFetchCacheAdapter } from '@knicola/xfetch'

const adapter: XFetchCacheAdapter = {
    get (key) {
        const { value, delta } = cache.get(key)
        const expiry = cache.ttl(key) + Date.now()
        return { value, delta, expiry }
    },
    set (key, { value, delta, ttl }) {
        cache.set(key, { value, delta }, ttl)
    },
}

const xfn = xfetch(fn, {
    key: 'cache-key',
    ttl: 30e3,
    adapter,
})
```
Use Redis as a cache adapter
```ts
import Redis from 'ioredis'

const redis = new Redis('redis://localhost:6379')

const adapter: XFetchCacheAdapter = {
    async get (key) {
        const res = await redis.multi()
            .hgetall(key)
            .pttl(key)
            .exec()
        const [[,{ value, delta }], [,ttl]] = res as [any, any]
        return { value, delta, expiry: Number(ttl) + Date.now() }
    },
    async set (key, { value, delta, ttl }) {
        await redis
            .multi()
            .hmset(key, { value, delta })
            .pexpire(key, ttl)
            .exec()
    },
}
```
### shouldRecompute()
Determine whether it's time to recompute the cached value
```ts
import { shouldRecompute } from '@knicola/xfetch'

const expiry = Date.now() + 3e3
const delta = 1e3
const beta = 1

shouldRecompute(expiry, delta, beta) //=> boolean
```
### compute()
Compute value and calculate duration of computation
```ts
import { compute } from '@knicola/xfetch'

const [value, delta] = await compute(() => fn())
```

## License

This project is open-sourced software licensed under the [MIT license](./LICENSE).
npm package: @knide/fs-prober
Description: fs-prober is a browser-friendly NPM package for extracting file and folder structures from user-selected files or directories.
Author: ashuvssut
Latest version: 1.0.2

# FS Prober

![FS Prober](./../docs/static/img/social-card.png)

The **FS Prober** package  is a browser-friendly NPM package for extracting file and folder structures from user-selected files or directories.

# What does it do?

The **FS Prober** package extends [react-dropzone](https://react-dropzone.js.org/) by adding support for *detecting empty folders*, including deeply nested ones. It maintains full compatibility with `react-dropzone`, adhering to the same props and return types while enhancing its functionality.

While `react-dropzone` provides a simple React hook for creating an HTML5-compliant drag-and-drop zone, it has limitations in detecting empty folders, as noted in this [GitHub issue](https://github.com/react-dropzone/react-dropzone/issues/986#issuecomment-687603291).

FS Prober uses standard file system APIs, ensuring that even empty folders within a directory structure are correctly detected. It is tested with the latest versions of Chrome, Firefox, Edge, and Safari and supports both the [File and Directory Entries API](https://developer.mozilla.org/en-US/docs/Web/API/File_and_Directory_Entries_API) and the [WICG File System Access API](https://developer.mozilla.org/en-US/docs/Web/API/File_System_API).

> [!NOTE]  
> File and Directory Entries API is available in all latest browsers. But the WICG File System Access API might not be available in all browsers yet.
> FS Prober uses File and Directory Entries API by default.

The FS Prober package extends the functionality of [`useDropzone`](https://react-dropzone.js.org/#usage) by using standard File System APIs, allowing it to detect even deeply nested empty folders.

## Installation

```sh
# NPM
npm install @knide/fs-prober

# Yarn
yarn add @knide/fs-prober
```

## Usage

Check out the [documentation](https://stacknide.github.io/fs-prober/docs/usage) for detailed usage instructions.
npm package: @knight0zh/mssql-mcp-server
Description: MCP server for connecting to MSSQL databases
Latest version: 0.1.1

# MSSQL MCP Server

A Model Context Protocol (MCP) server for connecting to Microsoft SQL Server databases. This server provides tools for executing SQL queries and managing database connections.

## Installation

```bash
npm install mssql-mcp-server
```

## Usage

Add the server to your MCP settings configuration file:

```json
{
  "mcpServers": {
    "mssql": {
      "command": "mssql-mcp-server",
      "env": {
        "MSSQL_CONNECTION_STRING": "Server=localhost;Database=master;User Id=sa;Password=yourpassword;",
        // Or individual connection parameters:
        "MSSQL_HOST": "localhost",
        "MSSQL_PORT": "1433",
        "MSSQL_DATABASE": "master",
        "MSSQL_USER": "sa",
        "MSSQL_PASSWORD": "yourpassword",
        "MSSQL_ENCRYPT": "false",
        "MSSQL_TRUST_SERVER_CERTIFICATE": "true"
      }
    }
  }
}
```

## Tools

### query

Execute a SQL query on a MSSQL database.

#### Parameters

- `connectionString` (string, optional): Full connection string (alternative to individual parameters)
- `host` (string, optional): Database server hostname
- `port` (number, optional): Database server port (default: 1433)
- `database` (string, optional): Database name (default: master)
- `username` (string, optional): Database username
- `password` (string, optional): Database password
- `query` (string, required): SQL query to execute
- `encrypt` (boolean, optional): Enable encryption (default: false)
- `trustServerCertificate` (boolean, optional): Trust server certificate (default: true)

Either `connectionString` OR (`host` + `username` + `password`) must be provided.

#### Example

```typescript
const result = await use_mcp_tool({
  server_name: 'mssql',
  tool_name: 'query',
  arguments: {
    host: 'localhost',
    username: 'sa',
    password: 'yourpassword',
    query: 'SELECT * FROM Users',
  },
});
```

## Development

```bash
# Install dependencies
npm install

# Run in development mode
npm run dev

# Build
npm run build

# Run tests
npm test

# Run linter
npm run lint

# Format code
npm run format
```

## License

MIT
npm package: @knight_42/octopus
Description: Yet another tiny and dedicated webhook handler
Author: knight_42
Latest version: 0.3.6

# Octopus

Yet another tiny, dedicated and extensible webhook handler.

## Installation

```
$ npm i @knight_42/octopus
```

## Usage

```javascript
import octopus from '@knight_42/octopus'
// The listening port can be specified via parameter or `process.env.PORT`
// By default, it is 8080
const hook = new octopus({ port: 10080 })

hook.github({ secret: 'IAmAToken' })
    .subscribe('issues', data => {
        console.log('new issues')
    })
    .subscribe('ping', data => {
        console.log('pong')
    })

hook.gitlab({ path: '/gitlab' })
    .subscribe('push', data => {
        console.log(data.object_kind)
    })
    .subscribe('merge_request_note', data => {
        console.log('new comments')
    })

hook.travisci({ path: '/notification' })
    .subscribe('*', console.log)
```

All available events can be found at:

* [GitHub events](https://github.com/knight42/octopus/blob/master/events/github_events.json)
* [GitLab events](https://github.com/knight42/octopus/blob/master/events/gitlab_events.json)
* [Travis-ci events](https://github.com/knight42/octopus/blob/master/events/travis_events.json)


And the data callback functions took is the request body (or the `payload` data for travis-ci) in JSON.

## Reference

* [GitHub webhook documentation](https://developer.github.com/webhooks/)
* [GitLab webhook documentation](https://docs.gitlab.com/ce/web_hooks/web_hooks.html)
* [Travis-ci webhook notifications](https://docs.travis-ci.com/user/notifications#Webhook-notifications)