1.0.0 • Published 6 years ago

radarsu v1.0.0

Weekly downloads
1
License
ISC
Repository
-
Last release
6 years ago

Description

Have you tried meteor, loopback, sails.js, nestjs and nothing suits your needs? Lack of WebSocket integration? No auto-generated swagger docs or CRUD? Overcomplicated structure with many concepts you do not really want to implement? Simple solution comes here.

Installation

npm i radarsu-core

Features

  • Integrated REST, GraphQL and WebSocket API.
  • Automatic validation of incoming requests.
  • Pretty logging to console and files with a well-configured Winston.
  • Auto-generated swagger docs and GraphQL panel.
  • Auto-generated CRUD client for all the models powered by Angular and Primeng.
  • CLI for generating various components based on templates that you can easiely modify.
  • RadarsuSocket Client and Server library allowing easy WebSocket communication between Client and Server:
// client side
const result = await ws.emit({
	action: `user/login`,
	args: [{
		login: `test`,
		password: `test`,
	}],
});
console.log(result); // 'NOT YET IMPLEMENTED';
// requests goes to the server through validation and other middleware
interface ILoginRequest {
	login: string;
	password: string;
}

@RadarsuController
@RadarsuMiddleware(exampleMiddleware, exampleGuard)
export class UserController {

	// body parameters are automatically validated based on ILoginRequest interface
    public login(@Body() body: ILoginRequest, rs: RadarsuSocket) {
	    return 'NOT YET IMPLEMENTED';
    }
}
  • Simple approach leaves everything as simple as possible, no coding redundancy, simple file structure:
  • src
    • 1-helpers - utility functions you like, your own little libraries.
    • 2-interfaces - types and interfaces.
    • 3-config - configuration of application and various libraries.
    • 4-entities - database models powered by sequelize-typescript.
    • 5-services - additional logics and storing data in server memory.
    • 6-middleware - filters, guards, interceptors, whatever you like as a middleware.
    • 7-controllers - routing and application entry point for all the REST, GraphQL and WebSocket Requests.
    • import - barrel import of every library and object you may need.
    • index.ts - application entry point (bootstrap).
  • data - place for logs and some server assets (like a favicon).
  • templates - place for templates that you can modify accodring to your needs, used to auto-generate components. Powered by ejs.

Drawbacks

In order to provide you with a well-configured setup of various libraries perfectly working together radarsu framework does not yet have adapters for other popular libraries. If you wish to switch from Winston to Bunyan or from Sequelize to other database, you need to rewrite initLogger, initDb, (...), methods.

import {
    Radarsu, config, radarsuLogger,
} from './import';

const log = radarsuLogger(__filename);

(async () => {
    config.app = new Radarsu();
    config.app.initLogger((options) => {
        // you are on your own here to return other logger you like
        return {};
    });
    await config.app.launch(config);
})();