Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/amaui-org/amaui-api

API
https://github.com/amaui-org/amaui-api

amaui api back-end backend decorators express expressjs js library node nodejs typescript utils web

Last synced: about 2 months ago
JSON representation

API

Awesome Lists containing this project

README

        



amaui logo

amaui API


API



MIT license    
Production ready    
100% test cov    
Nodejs


Very simple code    
Modern code    
Junior friendly    
Typescript    
Made with :yellow_heart:


## Getting started

### Add

```sh
yarn add @amaui/api
```

### Use

```javascript
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

```sh
yarn
```

Test

```sh
yarn test
```

### Prod

Build

```sh
yarn build
```