# aejo

> AJV + Express.js + JSONSchema + OpenAPI builder

Latest version **0.2.2** (published 2023-06-16) · MIT license · 0 weekly downloads

## Install

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

## Health

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

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

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.2 |
| Published | 2023-06-16 |
| First published | 2021-04-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 48 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | cawalch |
| Keywords | ajv, api, express, JSON, oas, openapi, schema, swagger, validate |

## Links

- npm: https://www.npmjs.com/package/aejo
- Repository: https://github.com/cawalch/aejo
- Homepage: https://github.com/cawalch/aejo#readme
- Issues: https://github.com/calwalch/aejo/issues
- npm.io page: https://npm.io/package/aejo

## Dependencies (3)

- [ajv](https://npm.io/package/ajv.md) ^8.0.5
- [express](https://npm.io/package/express.md) ^4.18.2
- [ajv-formats](https://npm.io/package/ajv-formats.md) ^2.0.2

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 0.2.2 (latest) — 2023-06-16
- 0.2.1 — 2023-04-16
- 0.2.0 — 2023-03-04
- 0.1.23 — 2022-09-06
- 0.1.22 — 2022-05-15
- 0.1.21 — 2022-02-15
- 0.1.20 — 2022-01-25
- 0.1.19 — 2022-01-24
- 0.1.18 — 2022-01-15
- 0.1.17 — 2021-07-16
- 0.1.16 — 2021-07-07
- 0.1.15 — 2021-07-02
- 0.1.14 — 2021-07-02
- 0.1.13 — 2021-06-15
- 0.1.12 — 2021-06-15
- … 12 more at https://npm.io/package/aejo/versions

## README

# AEJO

(AJV + Express.js + JSON Schema + OAS 3.x) API Builder

A library for building fully documented and validated Express API endpoints

- Composable functions based on OpenAPI 3.x schemas (fully typed)
- Generates OAS 3.x schemas
- Express.js Param, Query, Body validations via AJV
- Scoped auth strategies

## Query Params

```typescript
// Validate `limit` against `req.query`
Query({
  name: 'limit',
  description: 'max number',
  schema: {
    type: 'integer',
    minimum: 1,
  },
})
```

## Controller

```typescript
// Define a new controller using the `/api/users` path
Controller({
  prefix: '/api/users',
  // DI express router
  route: (router: Router): AppRoute =>
    Route(
      router,
      // Define a new path under the `/api/users` controller
      Path(
        '/',
        AsyncGet({
          tags: ['users'],
          description: 'List Users',
          // Define path parameters
          parameters: [
            Query({
              name: 'limit',
              description: 'max number',
              schema: {
                type: 'integer',
                minimum: 1,
              },
            }),
          ],
          // Middleware handlers
          middleware: [
            async (req: Request, res: Response, next: NextFunction) => {
              const users = await UserService(req.query)
              res.status(200).send(users)
            },
          ],
          // Endpoint Responses (testable)
          responses: {
            '200': {
              description: 'Success',
              content: UserListResponse,
            },
          },
        })
      )
    ),
})
```

## TODO

- [ ] Actual documentation
- [x] Publish npm
- [x] Better OAS support
- [x] More Tests

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