0.0.3-b • Published 5 months ago

sparkus v0.0.3-b

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

Installation

You can install Sparkus with npm:

npm install sparkus

or with yarn:

yarn add sparkus

Basic Usage

Here's a simple example of a Sparkus application:

// ./app.ts
import { App } from "sparkus/core";

// Bootstrap of your app
new App({
  // Folder to be scanned for automatic imports
  scan: [
    './src/controllers',
    './src/services',
  ],
  // The port needed your application
  port: 8080,
  // Automatically reload your files on save (enable this for development)
  watch: true
}).start();
// ./src/controllers/account.controller.ts
import { Controller, GET, Inject, InitLogger, POST } from "sparkus/decorators";
import { Logger } from "sparkus/utils";
import AccountService from "../services/account.service.js";

@Controller('/api/v1/account')
export default class AccountController {

    @InitLogger() // Automatically initialize the logger
    private logger: Logger;

    @Inject() // Automatically inject the service "accountService"
    private accountService: AccountService;

    @GET() // /api/v1/account
    public index(): any {
        const users = this.accountService.findAllUsers();
        return { hello: users };
    }

    @POST('/just/an/example') // /api/v1/account/just/an/example
    public create(): any {
        return { good: 'bye!' };
    }

}
// ./src/services/account.service.ts
import { Injectable } from "sparkus/decorators";

@Injectable('accountService')
export default class AccountService {

    public findAllUsers(): string[] {
        return ["Max", "Jeff", "Maria"]
    }

}

Documentation

Soon...

Contributing

Soon...

License

Sparkus is MIT licensed.

0.0.3

5 months ago

0.0.3-b

5 months ago

0.0.2-alpha

5 months ago

0.0.2-b-alpha

5 months ago

0.0.1-alpha

5 months ago