0.7.4 • Published 5 years ago

@iinfinity/rester v0.7.4

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

Rester

A RESTful server with db & session support based Koa & TypeScript.

FULL DOCUMENT IS HERE.

Attention

WARNING: This project is currently in an UNSTABLE phase.

STABLE version will be 1.0.0 in future.

Feature

  • support for creating cluster servers
  • database support
  • redis session support
  • static file support
  • CORS router support
  • RESTful api support
  • local session storage by Redion
  • Refactor project by DI & AOP, like Angular.

Change log

See Full Change Log on GitHub.

0.7.3 => 0.7.4

  • fix: fix database connection exception

0.6.0 => 0.7.0

  • feat: add development / production mode in Server Config
  • refactor: refactor namespace / module
  • perf: show middleware name when use
  • fix: fix some bugs & update package

Installation

This project has released on NPMJS.COM.

npm i --save @iinfinity/rester

DO NOT install koa and other dependencies AGAIN!

Usage

Quick Start

1. Install Rester

npm install --save @iinfinity/rester

2. Create index.ts file

And fill it with following code, see source code on GitHub.

import { RouterPaths, Rester, Option } from '@iinfinity/rester';

/** Router path. */
const GET: RouterPaths = {
  '/ get index': {
    path: '/',
    ware: async (c, next) => {
      next();
      c.body = 'Hello, world!';
    }
  }
};

/** Simple option. */
const option: Option = {
  router: {
    paths: { GET }
  }
};

const server = new Rester(option);

server.listen();

And then, run ts-node index.ts or tsc && node dist to start Rester.

Now, open your browser and enter localhost:8080, you will see Hello, world! on your screen.

See Full Document for more help.

Example

Advanced usage

Use your own middlewares.

server.use({
  'Middleware name': middleware,
  'another one': ware,
  'again': ware3,
  /** ... */
});

Thanks

Koa: Expressive HTTP middleware framework for Node.JS.

Koa Body: A full-featured koa body parser middleware.

Koa Router: Router middleware for koa.

Koa Static: Koa static file serving middleware, wrapper for koa-send.

Logger: TypeScript / JavaScript logger.

Redion: Session with redis.

TypeORM: Cross-platform ORM framework.

License

THE MIT LICENSE

Author

IInfinity, Email, Github, Home Page (Under construction).