open-index/open-npm huggingface dataset:
npm package: @marcj/marshal-nest
Description: A plugin for NestJS to convert HTTP Body to your class instance with validation using Marshal
Latest version: 2.1.13

# NestJS / Express for Marshal

[![npm version](https://badge.fury.io/js/%40marcj%2Fmarshal-nest.svg)](https://badge.fury.io/js/%40marcj%2Fmarshal-nest)

It's super common to accept data from a frontend via HTTP, transform the
body into your class instance, work with it, and then store that data in
your MongoDB or somewhere else. With Marshal this scenario is super
simple and you do not need any manual transformations.

```
npm install @marcj/marshal @marcj/marshal-mongo @marcj/marshal-nest
```

```typescript
import {
    Controller, Get, Param, Post, Body
} from '@nestjs/common';

import {SimpleModel} from "@marcj/marshal/tests/entities";
import {plainToClass, Database, classToPlain} from "@marcj/marshal";
import {ValidationPipe} from "@marcj/marshal-nest";
import {createConnection} from "typeorm";

@Controller()
class MyController {
    
    private database: Database;
    
    private async getDatabase() {
        if (!this.database) {
            const connection = await createConnection({
                type: "mongodb",
                host: "localhost",
                port: 27017,
                database: "testing",
                useNewUrlParser: true,
            });
            this.database = new Database(connection, 'testing');
        }
        
        return this.database;
    }
    
    @Post('/save')
    async save(
        @Body(ValidationPipe({transform: true})) body: SimpleModel,
    ) {
        body instanceof SimpleModel; // true;

        await (await this.getDatabase()).save(SimpleModel, body);
        
        return body.id;
    }
    
    @Get('/get/:id')
    async get(@Param('id') id: string) {
        const instance = await (await this.getDatabase()).get(SimpleModel, {_id: id});

        return classToPlain(SimpleModel, instance);
    }
}

````
npm package: @marckrenn/pi-sub-shared
Description: Shared types and event contract for the sub-* ecosystem
Latest version: 1.5.0

# @marckrenn/pi-sub-shared

Shared types, metadata, and event contracts for the `sub-*` ecosystem.

This package is consumed by `sub-core` and `sub-bar` to keep provider metadata, usage types, and model multipliers consistent. For repo setup and extension installation, see the root [pi-sub README](../../README.md).

## Overview

### Installation

```bash
npm install @marckrenn/pi-sub-shared
```

### Usage

```ts
import {
  PROVIDERS,
  ProviderName,
  UsageSnapshot,
  getDefaultCoreSettings,
} from "@marckrenn/pi-sub-shared";

const defaults = getDefaultCoreSettings();
const provider: ProviderName = "anthropic";
const snapshot: UsageSnapshot = {
  provider,
  displayName: "Anthropic (Claude)",
  windows: [],
};

console.log(PROVIDERS, defaults, snapshot);
```

### Exports

- `PROVIDERS`, `ProviderName`
- `RateWindow`, `UsageSnapshot`, `ProviderUsageEntry`
- `UsageError`, `UsageErrorCode`
- `ProviderStatus`, `StatusIndicator`
- `CoreSettings`, `CoreProviderSettings`, `CoreProviderSettingsMap`
- `BehaviorSettings`, `DEFAULT_BEHAVIOR_SETTINGS`
- `getDefaultCoreSettings`, `getDefaultCoreProviderSettings`
- `SubCoreState`, `SubCoreAllState`, `SubCoreEvents`
- `ProviderMetadata`, `ProviderDetectionConfig`, `ProviderStatusConfig`
- `PROVIDER_METADATA`, `PROVIDER_DISPLAY_NAMES`
- `MODEL_MULTIPLIERS`

## Development

```bash
npm run check
```

## Related docs

- Root README: [../../README.md](../../README.md)