@ineedthis/express
TypeScript icon, indicating that this package has built-in type declarations

0.2.2 • Public • Published

@ineedthis/express

npm version

Implements an ineedthis service for express.

Example

import {start, stop} from 'ineedthis';
import {createExpressService} from '@ineedthis/express';

const mySys = createExpressService('@myorg/webserver', {
  // number | (deps) => number | undefined (defaults to 3000)
  port: 3000,
  // read from env var example:
  // port: ({ '@company/my-config': config }) => config.PORT,

  // desired dependencies (same as ineedthis createService)
  dependencies: [ /*  */ ],

  // server: express server instance to decorate (add route handlers, etc.)
  // deps: object of fufilled dependencies
  setup(server, deps) {
    server.get('/', (req, res) => res.send('Hello, World!'));
  }
});

// Usage:
start(mySys).then(system => {
  // system is: { '@myorg/webserver': <express server> }

  // Server is now running!
  console.log(
    '@myorg/webserver running on port: ',
    system['@myorg/webserver'].address().port
  );

  stop(system).then(() => {
    // Server is now shutdown
  });
});

// Alternative usage:
export default mySys;
// and then run `ineedthis-run ./thisfile.js`
// or `ineedthis-debug ./thisfile.js` for hot-reloading

License

Released under the MIT License. See the LICENSE file for full text

Copyright © 2017 George Pittarelli

Readme

Keywords

none

Package Sidebar

Install

npm i @ineedthis/express

Weekly Downloads

0

Version

0.2.2

License

MIT

Unpacked Size

9.55 kB

Total Files

5

Last publish

Collaborators

  • ineedthis