open-index/open-npm huggingface dataset:
npm package: @opencasa/ioc
Description: a naive IOC container to be used
Author: sebastian real
Latest version: 2.1.0

# IOC

Simple container to hold dependencies and register factories.


# Install

```bash
$ npm install --save @opencasa/ioc
```

# Usage

```javascript
const IOC = require('@opencasa/ioc');
const container = new IOC();
```


# API

## container.add(dependencyName, dependency);

Adding a new dependency to the container is straightforward like this example below.

```javascript
  const cat = {
    name: 'Teo',
    age: 4
  };

  container.add('cat', cat);
```

If you add another dependency with the same name, the last dependency will replace the former one.

## container.get(dependencyName)

Getting a stored dependency in ioc.

```javascript
  const cat = container.get('cat');
  console.log('Cat name', cat.name); // Teo
```

By default each dependency stored in is a singleton.
If there is a need to remove the current instance after use, true can be passed
to remove the instance from the cached instances.

```javascript
  const cat = container.get('cat', true); // 1st time there is no issue, it will return cat instance
  const catError = container.get('cat'); // this will throw an error, due there is no cat instance on cache
```


## container.register(dependencyName, factory,[factoryDepencies])

Having a dependency already created is not always possible. To solve this issue, you can use a factory to create your dependency instead.

```javascript
  const makeCat = () => {
    return {
      name: 'Teo',
      age: 4
    };
  };

  constainer.register('cat', makeCat);
```

Additionally, if your factory needs dependencies which are already registered on container, you can refer them directly as follows.

```javascript
  // You will get your dependency list as an object
  const makeCat = ({ owner }) => {
    return {
      name: 'Teo',
      age: 4,
      askForFood() {
        console.log(`hey ${owner.name}, gimme some food`);
      }
    };
  };

  const owner = {
    name: 'Karen'
  };

  container.add('owner', owner);
  container.register('cat', makeCat, ['owner']);


  const theCat = container.get('cat');
  theCat.askForFood(); //hey Karen, gimme some food
```

## container.toDependencyObject()

When the dependency object is needed to be separated from container object, the dependency tree can be retrieved this way:

```javascript
  container.add('cat', cat);
  container.register('dog', () => dog);

  /*
    dependencies = {
      cat: catInstance,
      dog: dogInstance
    }
  */
  const dependencies = container.toDependencyObject();
```
npm package: @opencashdao/core
Description: OpenCashDAO is a decentralized autonomous organization (DAO) template for the Bitcoin Cash Blockchain.
Author: Kuldeep Singh
Latest version: 0.0.1

# @opencashdao/core

OpenCashDAO is a decentralized autonomous organization (DAO) template for the Bitcoin Cash Blockchain. It is designed to empower stakeholders/token holders to influence the project's direction. It serves as a proposal and voting platform enabling token holders to vote on various proposals to modify the project's functionality.


## Contract and Documentation
For more details, visit the [OpenCashDAO Contracts and Documentation](https://github.com/OpenCashDAO/opencashdao-contracts) repository.


## Usage

### Installation
```bash
npm install @opencashdao/core
```

### Setup
```js
import { createManager } from '@opencashdao/core';
```

## Support
For support, please open an issue on our GitHub repository or create a PR, or join our community chat at [Telegram](https://t.me/opencashdao).


## License

MIT
npm package: @opencashier/sdk
Description: Official Node.js SDK for the OpenCashier Merchant API.
Latest version: 0.2.0-beta.1

# @opencashier/sdk

Official Node.js / TypeScript SDK for the OpenCashier Merchant API.

## Requirements

- Node.js 18+

## Install

```bash
npm install @opencashier/sdk
```

```bash
pnpm add @opencashier/sdk
```

`baseUrl` must point to the Merchant API root such as `https://pay.example.com/api/v1`.

## Initialize A Client

```ts
import { OpenCashierClient } from "@opencashier/sdk";

const client = new OpenCashierClient({
  baseUrl: process.env.OPENCASHIER_BASE_URL!,
  merchant: {
    appId: process.env.OPENCASHIER_APP_ID!,
    appSecret: process.env.OPENCASHIER_APP_SECRET!
  }
});
```

## Create An Order

```ts
const order = await client.orders.create({
  merchantOrderNo: "ORDER_202603190001",
  amount: 100,
  currency: "CNY",
  subject: "Test order",
  description: "OpenCashier SDK example",
  notifyUrl: "https://merchant.example.com/pay/notify",
  returnUrl: "https://merchant.example.com/pay/result",
  allowedChannels: ["alipay_page"]
});

console.log(order.platformOrderNo);
console.log(order.cashierUrl);
```

The SDK signs merchant requests, injects standard OpenCashier headers, and applies a default idempotency key for write APIs.

## Verify Merchant Notifications

Keep the raw request body string and verify it before handling business logic:

```ts
const payload = client.notifications.verify<{
  notifyId?: string;
  eventType?: string;
  platformOrderNo?: string;
  merchantOrderNo?: string;
  status?: string;
}>({
  headers: request.headers,
  rawBody
});
```

After successful processing, your endpoint should return plain text `success`.

## Optional Provider Setup

If you also want to write app-scoped provider config from the same SDK, add admin credentials and call `client.providers.setup()`:

```ts
const client = new OpenCashierClient({
  baseUrl: process.env.OPENCASHIER_BASE_URL!,
  merchant: {
    appId: process.env.OPENCASHIER_APP_ID!,
    appSecret: process.env.OPENCASHIER_APP_SECRET!
  },
  admin: {
    username: process.env.OPENCASHIER_ADMIN_USERNAME!,
    password: process.env.OPENCASHIER_ADMIN_PASSWORD!
  }
});

await client.providers.setup({
  alipay: {
    authMode: "KEY",
    appId: process.env.ALIPAY_APP_ID!,
    privateKey: process.env.ALIPAY_PRIVATE_KEY!,
    publicKey: process.env.ALIPAY_PUBLIC_KEY!,
    gateway: process.env.ALIPAY_GATEWAY!,
    productCapabilities: ["PAGE"]
  }
});
```

## Errors

```ts
import { OpenCashierApiError } from "@opencashier/sdk";

try {
  await client.orders.create({
    merchantOrderNo: "ORDER_202603190001",
    amount: 100,
    currency: "CNY",
    subject: "Test order",
    notifyUrl: "https://merchant.example.com/pay/notify"
  });
} catch (error) {
  if (error instanceof OpenCashierApiError) {
    console.error(error.status, error.code, error.requestId, error.message);
  }
}
```

## Documentation

- English guide: <https://opencashier-docs.vercel.app/en/node-sdk>
- Chinese guide: <https://opencashier-docs.vercel.app/zh-CN/node-sdk>