Introduction
Express endpoints is a framework for astro.js that allows you to create express-like endpoints in astro.js.
Some of the features:
- ✅ Body, Query, Params, Headers parsers
- ✅ Express Middleware
- ✅ JWT session (if you use astro-utils/forms)
- ✅ Body validator (via
zod-express-middleware
)
- ✅ Send JSON, files, and HTML easily
Installation
Usage
The validation options apply only to the next route.
Meaning that you can use the same router for multiple methods.
Body options
The default body-parser is auto
meaning that it will parse the body no matter the type of it including multipart/form-data
.
You can configure the body parser by calling the body
method.
The body parser options are the same as formidable
.
You can call the body
method multiple times, only the last one will be used for the next route.