@amaui/api
TypeScript icon, indicating that this package has built-in type declarations

1.0.38 • Public • Published

amaui logo

amaui API

API


MIT license     Production ready     100% test cov     Nodejs

Very simple code     Modern code     Junior friendly     Typescript     Made with 💛


Getting started

Add

  yarn add @amaui/api

Use

  import express from 'express';
  import { Route, Method, IRouteClassInstance, Routes } from '@amaui/api';

  class Base implements IRouteClassInstance {

    public response(req: express.Request, response: express.Response, options: { method: 'json' | 'send', type: 'application/json', }) { return ...; }

    public error(req: express.Request, error: Error) { return ...; }

  }

  // Add decorator to a class representing a route
  @Route(
    '/a',
    method
  )
  class A extends Base {

    @Method(
      'get',
      '/a',
      method1
    )
    public a() { }

  }

  // Create an express app
  const app = express();

  // Register all classes as app routes
  Routes([A], app);

  // app routes:
  // GET /a/a, middlewares: method, method1

  // etc.

Dev

Install

  yarn

Test

  yarn test

Prod

Build

  yarn build

Package Sidebar

Install

npm i @amaui/api

Weekly Downloads

49

Version

1.0.38

License

MIT

Unpacked Size

54.7 kB

Total Files

12

Last publish

Collaborators

  • lazareric