0.24.0 • Published 2 years ago

@macchiatojs/kernel v0.24.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

@macchiatojs/kernel

Installation

# npm
$ npm install @macchiatojs/kernel
# yarn
$ yarn add @macchiatojs/kernel

Usage

I'm working to add full documentations as soon as possible <3.

// Express/Connect Style
import Macchiato, { Request, Response, Next } from "@macchiatojs/kernel";

const app = new Macchiato();

app.use((request: Request, response: Response, next?: Next) => {
  response.body = "Hello World !"; // also you can use .send(200, "Hello World !")
});

app.start(2222);

// Koa Style
import Macchiato, { Context, Next } from "@macchiatojs/kernel";

const app = new Macchiato({ expressify: false });

app.use((context: Context, next?: Next) => {
  context.response.body = "Hello World !"; // also you can use .send(200, "Hello World !")
});

app.start(2222);

If you want to use the famous koa-compose for mws;

import Macchiato, { Context, Next } from "@macchiatojs/kernel";
// don't forget to add '@macchiatojs/wrap-koa-compose' and 'koa-compose'
import WrapKoaCompose from "@macchiatojs/wrap-koa-compose";

const app = new Macchiato({
  koaCompose: new WrapKoaCompose<Context, Next>(),
});

Support

If you have any problem or suggestion please open an issue.

License


MIT © Imed Jaberi