Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@mikrokit/serverless

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mikrokit/serverless

MikroKit Serverless Router for quick Api development.

  • 0.2.1-alpha.0
  • unpublished
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

MikroKit, The APi Dashboard

MikroKit Serverless Router for quick Api development.

Travis npm npm

@mikrokit/serverless

MikroKit Router is an RPC like router oriented for quick Api development,   it is agnostic about the server or serverless environment it is used on. It could be used on aws lambda, azure functions, Google cloud functions, or any event based environment.

This package contains a collection bindings for different serverless environments.

RPC like router

MikroKit router uses a Remote Procedure Call style routing, unlike traditional routers it does not use GET, PUT, POST and DELETE methods, everything is transmitted using HTTP POST method and all data is sent/received in the request/response body and headers.

Requests & Responses

  • Requests are made using only HTTP POST method.
  • Data is sent and received only in the body and headers.
  • Data is sent and received only in JSON format.

Routing

🚀 Lightweight router based in plain javascript objects.

Thanks to it's RPC style there is no need to parse parameters or regular expressions when finding a route. Just a simple Map in memory containing all the routes.

Route parameters are passed as an array in the request body, in a field with the same name as the route. Elements in the array must have the same order as the function parameters.

Route response is send back in the body in a field with the same name as the route.

The reason for this weird naming is to future proof the router to be able to accept multiple routes on a single request. However this can be changed setting the routeFieldName in the router options.

📋 Please read full router documentation here!

// ../router/examples/routes-definition.routes.ts

import {Route, Handler, Routes, MkRouter} from '@mikrokit/router';

const sayHello: Handler = (context, name: string): string => {
  return `Hello ${name}.`;
};

const sayHello2: Route = {
  route(context, name1: string, name2: string): string {
    return `Hello ${name1} and ${name2}.`;
  },
};

const routes: Routes = {
  sayHello, // api/sayHello
  sayHello2, // api/sayHello2
};

MkRouter.setRouterOptions({prefix: 'api/'});
MkRouter.addRoutes(routes);

MIT LICENSE

Keywords

FAQs

Package last updated on 29 Oct 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc