# @levrbet/shared

Shared utilities, components, and types for the LEVR platform...

## Installation

```bash
npm install @levrbet/shared @prisma/client
```

The Prisma client is automatically generated during installation - no additional setup required.

## Usage

```typescript
// Core utilities (universal - works in both browser and Node.js)
import { e18, LevrBaseMarket } from "@levrbet/shared/core"

// Prisma types and client
import { PrismaClient, GamePhase, MarketStatus } from "@levrbet/shared/core"
// Or directly from @prisma/client
import { PrismaClient, GamePhase } from "@prisma/client"

// Server-only utilities
import { authMiddleWare, validateApiKey } from "@levrbet/shared/server"

// React components and hooks
import { useAuth } from "@levrbet/shared/react"
```

## Credentials

`SERVICE_API_KEY_ID` and `SERVICE_API_KEY_SECRET` are LEVR HMAC credentials used to sign service-to-service requests. They are not AWS credentials.

AWS clients use the standard AWS SDK credential provider chain, which includes environment variables such as `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY`. Deployed workloads should instead receive temporary credentials from their ECS task role or Lambda execution role; `@levrbet/shared` does not parse or inject static credentials itself.

## Package Structure

-   **`/core`** - Blockchain contracts, types, Prisma re-exports, and universal utilities
-   **`/server`** - Node.js server utilities (auth, database, logging, middleware)
-   **`/react`** - React components and hooks

## Peer Dependencies

This package requires the following peer dependencies:

| Package                 | Required For                 |
| ----------------------- | ---------------------------- |
| `@prisma/client`        | Database types and client    |
| `react`                 | React hooks (optional)       |
| `@tanstack/react-query` | React query hooks (optional) |
| `@privy-io/react-auth`  | Privy auth hooks (optional)  |

## Prisma

The Prisma schema is bundled in this package and the client is auto-generated on install. If you need to manually regenerate:

```bash
npx levrbet-prisma-setup
# Or directly:
npx prisma generate --schema=node_modules/@levrbet/shared/prisma
```

## Development

```bash
npm install          # Install dependencies
npm run build        # Build package
npm run dev          # Build and pack for local testing
```

### Local Testing

```bash
# In this package
npm run dev  # Creates a .tgz file

# In consumer project
npm install /path/to/levr-shared/*.tgz
```

## License

Proprietary to LEVR Labs.
