0.2.2 • Published 11 months ago
aejo v0.2.2
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
// Validate `limit` against `req.query`
Query({
name: 'limit',
description: 'max number',
schema: {
type: 'integer',
minimum: 1,
},
})
Controller
// 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
- Publish npm
- Better OAS support
- More Tests
0.2.2
11 months ago
0.2.1
1 year ago
0.2.0
1 year ago
0.1.22
2 years ago
0.1.23
2 years ago
0.1.20
2 years ago
0.1.21
2 years ago
0.1.18
2 years ago
0.1.19
2 years ago
0.1.17
3 years ago
0.1.16
3 years ago
0.1.14
3 years ago
0.1.15
3 years ago
0.1.12
3 years ago
0.1.13
3 years ago
0.1.11
3 years ago
0.1.10
3 years ago
0.1.8
3 years ago
0.1.7
3 years ago
0.1.9
3 years ago
0.1.6
3 years ago
0.1.5
3 years ago
0.1.4
3 years ago
0.1.2
3 years ago
0.1.1
3 years ago
0.1.3
3 years ago
0.1.0
3 years ago