oly-api
TypeScript icon, indicating that this package has built-in type declarations

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

Dependencies (10)

Dev Dependencies (6)

Package Sidebar

Install

npm i oly-api

Weekly Downloads

2

Version

1.1.0

License

MIT

Unpacked Size

189 kB

Total Files

217

Last publish

Collaborators

  • nolyme