npm

Share private packages across your team with npm Orgs, now with simplified billing via the aws marketplace!Learn more »

oly-api

1.1.0 • Public • Published

oly api

REST API with koa and decorators.

oly api is a module of the oly project.

import { inject, Kernel } from "oly";
import { ApiProvider, get } from "oly-api";
 
class Repo {
  query = () => Promise.resolve([1, 2, 3]);
}
 
class Api {
  @inject repo: Repo;
 
  @get("/users")
  async findUsers() {
    return await this.repo.query();
  }
}
 
Kernel
  .create({
    HTTP_SERVER_PORT: 6000,
  })
  .with(Api, ApiProvider)
  .start()
  .catch(console.error);
 
// curl http://localhost:6000/api/users -> [1,2,3]

Installation

$ npm install oly oly-api

install

npm i oly-api

Downloadsweekly downloads

5

version

1.1.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability