Skip to content

Zept is in development.

The current package on which zely is based is osik.
osik was not originally developed for zely. So when developing zely, we adapted and used osik (since updating osik would deviate from the original development intent).

But now you can use zept, which is optimized for zely!

Installation

You can install zept via npm.

bash
npm install --save-dev zept
npm install --save-dev zept
ts
import { zept } from 'zept';
import { zept } from 'zept';

Usage

ts
zept([
  /* routes */
]);
zept([
  /* routes */
]);

zept() creates a new zept server.

The routes should look like below.

ts
const routes = [
  {
    path: '/',
    module: (req, res) => {
      // ...
    },
  },
];
const routes = [
  {
    path: '/',
    module: (req, res) => {
      // ...
    },
  },
];

And if you want the server to respond only when req.method is POST, enter the following:

ts
const routes = [
  {
    path: '/',
    module: {
      POST: (req, res) => {
        // ...
      },
    },
  },
];
const routes = [
  {
    path: '/',
    module: {
      POST: (req, res) => {
        // ...
      },
    },
  },
];

@zept/http

The new name for osik is @zept/http.

So did this just change the name? No.

Some features have been added.
For example, a processor is created that runs after all middleware is executed.

ts
const { ZeptServer } = require('@zept/http');
const server = new ZeptServer();

server.useProcessor((req, res, next) => {
  console.log('processor called');
  next();
});
server.use((req, res, next) => {
  console.log('middleware called');
  next();
});

server.listen(3000);
const { ZeptServer } = require('@zept/http');
const server = new ZeptServer();

server.useProcessor((req, res, next) => {
  console.log('processor called');
  next();
});
server.use((req, res, next) => {
  console.log('middleware called');
  next();
});

server.listen(3000);
$ node ./server.js
middleware called
processor called
$ node ./server.js
middleware called
processor called

Future Plans

zept has not been applied to zely yet. zept will be applied from the next version.