Zephyr is a Typescript server-side meta framework that is inspired by Next.js for its file-based routing. It is built on top of Express.js and uses Zod in request / response validation as well as providing typesafe API.
Zephyr places a high value on FP (Functional Programming). Instead of using classes as API controllers, declare and export API routes with functions.
The established server-side web frameworks for Node.js at the moment are Nest.js and Adonis.js, both of which are fantastic and rely on controllers and decorators in OOP. However, some programmers prefer functional programming to object-oriented programming (OOP). As a result, Zephyr seeks to let programmers to define API routes with functions and provides file-based routing out of the box.
Kindly visit our documentation on zephyrjs.com
Bootstrapping Project
npm create zephyr-app <app-name>
yarn create zephyr-app <app-name>
pnpm create zephyr-app <app-name>
Defining API Route
// src/routes/login.ts
import { defineRoute } from '@zephyr-js/core';
// POST /login
export function POST() {
return defineRoute({
schema: z.object({
body: z.object({
email: z.string(),
password: z.string(),
}),
response: z.object({
success: z.boolean(),
}),
}),
onRequest(req) {
logger.info('Request received', req.method, req.path);
},
async handler({ body }) {
await login(body);
return { success: true };
},
onErrorCaptured(req, res, err) {
logger.error('Login failed', err);
res.status(500);
return { success: false };
},
});
}
- Complete
create-zephyr-app
- Publish
@zephyr-js/core
,@zephyr-js/common
andcreate-zephyr-app
to NPM - Create unit tests
- Supports dependency injection
- Create
zephyr
cli