0.1.0 • Published 3 years ago

@nowts/core v0.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

NowTS

This work is in progress

Installation

yarn

yarn add @nowts/core

npm

npm install --save @nowts

Get Started

import * as bodyParser from 'body-parser';
import * as express from 'express';
import {
  NowModule,
  Injectable,
  newExpressDecorator,
  RestController,
} from '@nowts/core';

@Injectable()
class User implements RestController {
  constructor() {}

  async create(id, data, params) {
    console.log(params.query);
    data.createdAt = Date.now();
    return data;
  }
}

const app = express();
const now = new NowModule({
  services: [User],
  controllerBindings: [rest.bindController('/users', User)],
  sharedControllerDecorators: [
    newExpressDecorator(bodyParser.urlencoded({ extended: false })),
    newExpressDecorator(bodyParser.json()),
  ],
});
app.use(now.expressRouter());
app.listen(3000, () => console.log('Listening ...'));

Documentation

Find docs here.

Contributing

There are several way to contribute.

  • Submit a PR to fix typos/grammatical errors.
  • Open an issue to report a bug.
  • Open an issue to suggest a new feature.
  • Improve the docs.

Packages

License

MIT