microwizard-service-loader-es

1.6.4 • Public • Published

Seneca

A Seneca.js Structure Plugin

seneca-service-loader

npm version Dependency Status

Lead Maintainer: Tobias Gurtzick

seneca-service-loader-es

This module is a plugin for the Seneca framework. It provides you with capabilities to cleanly structure your services.

Usage

To use the service-loader first install the module via

npm i -s seneca-service-loader-es

Now you can require the plugin and use it, like in the following example:

'use strict';

import Service from 'seneca-service-loader-es';
import seneca from 'seneca';
import MariaDB from 'hapi-mariadb';

const service = new Service(seneca);
service
  .register([
    {
      register: MariaDB,
      options: {
        mariasql: config.database,
        connectionCount: 8,
        poolAsPromised: true,
      },
    },
  ])
  .then(() => service.load());

Now it will allow you to load any file from lib/controllers/*.js. A service looks like this:

'use strict';

module.exports = {
  pin: 'my:pin,command:name':,
  request: async (request, data) => {
    return null;
  }
}

The example provided here also registers a hapi plugin. Quite simple plugins for hapi do work with this module. Like most database modules. This is intended to produce a better overall experience, by accessing APIs everywhere in the same way.

Package Sidebar

Install

npm i microwizard-service-loader-es

Weekly Downloads

1

Version

1.6.4

License

MIT

Unpacked Size

10.5 kB

Total Files

7

Last publish

Collaborators

  • wzrdtales