# @maxbuild/middleware-cosr-data

> cosr data

Latest version **0.0.5** (published 2022-01-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install @maxbuild/middleware-cosr-data
pnpm add @maxbuild/middleware-cosr-data
yarn add @maxbuild/middleware-cosr-data
bun add @maxbuild/middleware-cosr-data
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.5 |
| Published | 2022-01-04 |
| First published | 2021-12-31 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=10 |
| Dependencies | 2 |
| Unpacked size | 59.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | fiathux, brainpoint |

## Links

- npm: https://www.npmjs.com/package/@maxbuild/middleware-cosr-data
- npm.io page: https://npm.io/package/@maxbuild/middleware-cosr-data

## Dependencies (2)

- [bpframework](https://npm.io/package/bpframework.md) ^0.3.13
- [cassandra-driver](https://npm.io/package/cassandra-driver.md) ^4.6.3

## Recent versions

- 0.0.5 (latest) — 2022-01-04
- 0.0.4 — 2021-12-31
- 0.0.3 — 2021-12-31
- 0.0.2 — 2021-12-31
- 0.0.1 — 2021-12-31

## README

# MAXBUILD service cosr data middleware in bpframework.

### Middleware specification

https://github.com/bpcloud/middleware

### usage

```js
import {BillService, billNextPage} from '@maxbuild/middleware-cosr-data';

@Service
class TestService {

  @Autowired(BillService)
  billService: BillService;

  // query instance.
  async testQuery():Promise<any> {
    let res = await this.billService.billQueryInstance('tablename', {
      ownerId: 'xxxxxx',
      //instanceId: 'xxxxxxx',
      productCode: 'cdn',
      start_at: new Date(Date.UTC(2020, 6, 17)),
      // end_at: new Date(Date.UTC(2021, 6, 18)),
      // limit: 1,
    });

    do {
      console.log(res.rowLength);
    } while (billNextPage(res));
    console.log('query finish');
  }

  // execute.
  async testExecute():Promise<any> {
    let sql = 'UPDATE users SET birth = ? WHERE key=?';
    let params = [ new Date(1942, 10, 1), 'jimi-hendrix' ];
   
    let res = await this.billService.execute(sql, params);
    do {
      console.log(res.rowLength);
    } while (billNextPage(res));
    console.log('query finish');
  }
}

```


#### Setup.

```js

import { Application } from 'bpframework';
import * as middleware_cosr_data from '@maxbuild/middleware-cosr-data';

Application.use(middleware_cosr_data.middleware())
Application.runKoa(...);
```

#### Config.

```properties
cosr_data:
  cassandra:
    contactPoints:
    - localhost:30042
    localDataCenter: datacenter1
    keyspace: cfm
    # 认证信息(非必须)
    credentials:
      username: string
      password: string
    # 超时信息(非必须)
    socketOptions:
      connectTimeout: number
      readTimeout: number
```

---
_Source: https://npm.io/package/@maxbuild/middleware-cosr-data · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
