# mockci

> This is the npm package to use the MockCI API.

Latest version **1.0.6** (published 2022-07-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install mockci
pnpm add mockci
yarn add mockci
bun add mockci
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.6 |
| Published | 2022-07-09 |
| First published | 2022-07-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 6.6 KB |
| Known vulnerabilities | 0 (+23 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | plenituz |
| Keywords | dynamodb, dynamodb local, dynamodb mock, dynamodb testing, aws, aws dynamodb, amazon, amazon web services, mockci |

## Links

- npm: https://www.npmjs.com/package/mockci
- Repository: https://github.com/mock-ci/npm-mockci
- Homepage: https://mockci.cloud/
- Issues: https://github.com/mock-ci/npm-mockci/issues
- npm.io page: https://npm.io/package/mockci

## Dependencies (1)

- [axios](https://npm.io/package/axios.md) ^0.27.2

## Alternatives

- [duck](https://npm.io/package/duck.md) — 4.2M weekly downloads
- [ava](https://npm.io/package/ava.md) — 560.2K weekly downloads
- [storybook-addon-module-mock](https://npm.io/package/storybook-addon-module-mock.md) — 71.7K weekly downloads
- [vest](https://npm.io/package/vest.md) — 50.1K weekly downloads
- [@ethereum-waffle/mock-contract](https://npm.io/package/@ethereum-waffle/mock-contract.md) — 40.0K weekly downloads

## Recent versions

- 1.0.6 (latest) — 2022-07-09
- 1.0.5 — 2022-07-06
- 1.0.4 — 2022-07-06
- 1.0.3 — 2022-07-06
- 1.0.2 — 2022-07-06
- 1.0.1 — 2022-07-06
- 1.0.0 — 2022-07-06

## README

# [MockCI](https://mockci.cloud) npm package

This is the npm package to use the MockCI API.

[MockCI](https://mockci.cloud) creates a DynamoDB compatible endpoint that you can use and throwaway.
This allows you to test all you DynamoDB related code locally with minimal changes.

install:
```bash
npm install mockci
# or
yarn add mockci
```

example usage:

```ts
import { MockCIPrefab, MockCISession } from 'mockci'
import { DynamoDBClient, ScanCommand, ScanCommandInput } from "@aws-sdk/client-dynamodb";

type DynamoDBItem = {
    id: string
    value: string
}

async function generateDdbEndpoint() {
    const prefab: MockCIPrefab = {
        "dynamodb": {
            "tables": [
                {
                    "seedData": [
                        {
                            "id": generateName(),
                            "value": "seeded value"
                        }
                    ],
                    "name": "generic-table",
                    "attributes": [
                        { "name": "id", "type": "S" },
                    ],
                    "hashKey": "id"
                }
            ]
        }
    }
    const endpointBlob = await MockCISession.start({ prefab })
    return endpointBlob.dynamodbEndpoint
}

async function listDDBItems(ddbClient: DynamoDBClient): Promise<DynamoDBItem[]> {
    const params: ScanCommandInput = {
        TableName: 'generic-table',
    }
    const data = await ddbClient.send(new ScanCommand(params));
    return data.Items.map((element) => ({
        id: element.id.S,
        value: element.value.S,
    }))
}

//this is optional, you can try out the DynamoDB mock without using an API key,
//if you reach the api limits of anonymous sessions,
//head to [the [MockCI]()](https://mockci.cloud/signup) website to get a free API key.
MockCISession.setAPIKey('YOUR_API_KEY_HERE')

generateDdbEndpoint()
.then((endpoint) => {
    let ddbClient = new DynamoDBClient({
        region: 'us-east-1',
        endpoint,
        credentials: {
            //if you're in the browser this is required (but can be any value)
            //if you're in Node and have a local AWS profile configure, this is optional
            accessKeyId: 'anyvalueworks',
            secretAccessKey: 'anyvalueworks',
        }
    })
    return listDDBItems(ddbClient)
})
.then(console.log)
```

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