https://github.com/onesy-me/apis
API
https://github.com/onesy-me/apis
amaui api back-end backend decorators express expressjs js library node nodejs typescript utils web
Last synced: 3 months ago
JSON representation
API
- Host: GitHub
- URL: https://github.com/onesy-me/apis
- Owner: onesy-me
- License: mit
- Created: 2022-02-03T16:04:03.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2025-04-08T18:09:18.000Z (about 1 year ago)
- Last Synced: 2025-04-14T11:07:46.421Z (about 1 year ago)
- Topics: amaui, api, back-end, backend, decorators, express, expressjs, js, library, node, nodejs, typescript, utils, web
- Language: TypeScript
- Homepage: https://docs.onesy.me/library/api
- Size: 416 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
onesy APIs
MIT license
Production ready
100% test cov
Nodejs
Very simple code
Modern code
Junior friendly
Typescript
Made with :yellow_heart:
### Add
```sh
yarn add @onesy/api
```
### Use
```javascript
import express from 'express';
import { Route, Method, IRouteClassInstance, Routes } from '@onesy/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
```