piax
v0.1.3
Published
A modern, type-safe HTTP framework for Node.js
Maintainers
Readme
Piax
A modern, type-safe HTTP framework for Node.js, built with TypeScript.
[!WARNING] This project is under heavy development. Not ready for production use.
Quick Start
Create a new project
npm create piax@latest
# or using pnpm
pnpm create piax@latest
# or via yarn
yarn create piaxInstall & run
cd <my-app>
npm install
npm run devExamples
Basic App
import { Piax } from 'piax'
const app = new Piax()
app.get('/', () => 'Hello Piax!')
app.listen(2332)Basic Routing
import { Piax } from 'piax'
const app = new Piax()
// Route params (type-safe)
app.get('/user/:id', (ctx) => {
return { id: ctx.params.id } // ✅ parsed & type-safe
})
// Query params
app.get('/search', (ctx) => {
return { query: ctx.query.q }
})
// POST with body
app.post('/posts', (ctx) => {
return { data: ctx.body }
})
app.listen(2332)Context
The ctx object provides request/response utilities:
Properties
ctx.method- HTTP method (GET, POST, etc.)ctx.path- Request pathctx.url- Full request URLctx.params- Route parameters (type-safe)ctx.query- Query string parametersctx.headers- Request headersctx.body- Request body (parsed)ctx.status- Response status code
Methods
ctx.json(data)- Send response jsonctx.text(text)- Send response text
Links
📄 License
MIT License
