Skip to content

A tiny wrapper for express.js to automatically register your service in consul

Notifications You must be signed in to change notification settings

kerwitz/with-consul

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This is a very simple helper that will hook in on the .listen function of your express app to automatically register a new service instance to consul.

Installation

npm i -D with-consul

npm npm

Usage

const withConsul = require('with-consul');
const express = require('express');

const app = withConsul(express(), {
    name: 'my-service',
    address: 'localhost',
    tags: ['urlprefix-/my-service'],
});

const server = app.listen(0, () => {
    console.log(`Example app listening on port ${server.address().port}!`);

    app.get('/', () => {});
});

By default the package will create a new UUID for the service instance but you can overwrite it by providing your own id in the options.

About

A tiny wrapper for express.js to automatically register your service in consul

Resources

Stars

Watchers

Forks

Packages

No packages published