New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

kobp

Package Overview
Dependencies
Maintainers
1
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

kobp

Koa Boilerplate with MikroORM

  • 0.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
361
decreased by-2.96%
Maintainers
1
Weekly downloads
 
Created
Source

Kobp

Start your Koa project with necessary Boring codes.

Install

npm i --save kobp

# OR

yarn kobp

NOTE we listed koa as our peerDependencies so please include the koa in your own codebase.

Usage

Start your node.js TypeScript project and describe your endpoints with controller style.

To expose each method as routes. Use our built-in decorator. Route which accepts method, paths, and Koa's middlwares.

controllers/hello.cotnroller.ts

import type { KobpServiceContext } from 'kobp'
import { Route, BaseRoutedController } from 'kobp'

export class HelloController extends BaseRoutedController {

  @Route('post', '/echo')
  async migrate(context: KobpServiceContext) {
    return context.request
  }

  @Route()
  async index(context: KobpServiceContext) {
    return {
      hello: 'world'
    }
  }
}

Or you can describe your controllers in a classical way. (Avoid using decorators). This method introduce less code when it is bundled.

controllers/hello.controller.ts

import type { KobpServiceContext } from 'kobp'
import { RouteMap, BaseRoutedController } from 'kobp'

export class HelloController extends BasedRouteController {

  public getRouteMaps(): RouteMap {
    return {
      ...super.getRouteMaps(),
      index: { method: 'get', path: '/', middlewares: [] }, // Same as our decorator above.
    }
  }

  async index(context: KobpServiceContext) {
    return {
      hello: 'world'
    }
  }
}

Now to utilise this controller. Simply use Koa as your application with our boiler plate.

server.ts

export default makeServer((koa) => {
}, {
  port: 9000
})

By the example above. You will be able to:

curl -XGET http://localhost:9000/hello/hi

TODO

[ ] Example repo
[ ] Inter Service Communication
[ ] SNS/SQS Handler

Keywords

FAQs

Package last updated on 16 Apr 2021

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