# express-zod-contract

> ## Installation

Latest version **0.0.3** (published 2023-05-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install express-zod-contract
pnpm add express-zod-contract
yarn add express-zod-contract
bun add express-zod-contract
```

## Health

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

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.3 |
| Published | 2023-05-24 |
| First published | 2023-05-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 3 |
| Unpacked size | 32.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Nathan Russell |
| Maintainers | nathan.russell.dev |

## Links

- npm: https://www.npmjs.com/package/express-zod-contract
- npm.io page: https://npm.io/package/express-zod-contract

## Dependencies (3)

- [zod](https://npm.io/package/zod.md) ^3.21.4
- [express](https://npm.io/package/express.md) ^4.18.2
- [zod-validation-error](https://npm.io/package/zod-validation-error.md) ^1.3.0

## Recent versions

- 0.0.3 (latest) — 2023-05-24
- 0.0.2 — 2023-05-24
- 0.0.1 — 2023-05-24

## README

# Express zod contract

## Installation

```sh
# npm
npm i express-zod-contract

# yarn
yarn add express-zod-contract

# pnpm
yarn add express-zod-contract
```

## Examples

With the type inference, it's pretty straight forward how it works.

```typescript
import * as express from "express";
import { contract } from "express-zod-contract";
import { z } from "zod";

const app = express();

app.get(
  "/:name",
  contract({
    params: z.object({
      name: z.string().max(10),
    }),
    result: z.string(),
    handler: (inputs, ctx) => {
      return { greeting: "Hello " + inputs.name };
    },
  })
);

app.listen(3000, () => console.log("Server listening on http://localhost:3000"));
```

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