Git Product home page Git Product logo

zephyr's Introduction

Zephyr.js logo

Zephyr.js

Build Typesafe Node API in minutes

Zephyr.js CI workflow CodeFactor

Description

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.

Philosophy

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.

Getting started

Kindly visit our documentation on zephyrjs.com

Overview

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 };
    },
  });
}

TODO

  • Complete create-zephyr-app
  • Publish @zephyr-js/core, @zephyr-js/common and create-zephyr-app to NPM
  • Create unit tests
  • Supports dependency injection
  • Create zephyr cli

zephyr's People

Contributors

kakengloh avatar marvin-j97 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

zephyr's Issues

(create-zephyr-app) Prompt choice between yaml and json

I personally quite dislike yaml, so the first thing I'd always do after using create-zephyr-app would be converting those back to json.
It would be nice to be able to choose between json and yaml, and write prettierrc.yml and eslintrc.yml on demand using JSON or YAML (https://www.npmjs.com/package/yaml).
It would also help in the future for modifying those configs (like choosing different rule sets if the user wants to).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.