0.0.17 • Published 4 years ago

@something.technology/microservice-utilities v0.0.17

Weekly downloads
301
License
MIT
Repository
-
Last release
4 years ago

@something.technology/microservice-utilities

Utilities, e.g. when working with express microservices.

Express

Environment variables:

Namedefault valuedescription
PORT3000Port on which the express server will run
HEALTHCHECK_IP-IP address which is allowed to perform the healthcheck

Healthcheck

We provide a helper function to make it easy to add a healthcheck to your express application. You need to provide the HEALTHCHECK_IP env variable. If the env variable is not set, every client is allowed to perform the healthcheck.

Usage:

import express from 'express'
import { logger, healthcheck } from '@something.technology/microservice-utilities';

const PORT = process.env.PORT || 3000
const HEALTHCHECK_ROUTE = process.env.HEALTHCHECK_ROUTE || '/health'

const run = async (): Promise<void> => {
  try {
    const app = express()

    app.get('/', (_, res) => {
      res.send('Hello Something!')
    })

    app.get(HEALTHCHECK_ROUTE, healthcheck);

    app.listen(PORT, () => {
      logger.info(`Example app listening at http://localhost:${PORT}`)
    })

  } catch (e) {
    logger.error(e);
  }
};

run().then(() => {});

When running the core init script npx @something.technology/core init . this boilerplate code will be created automatically for you.

0.0.17

4 years ago

0.0.16

4 years ago

0.0.15-beta.0

4 years ago

0.0.15

4 years ago

0.0.14

4 years ago

0.0.13

4 years ago

0.0.12

4 years ago

0.0.10

4 years ago

0.0.11

4 years ago

0.0.9-beta.0

4 years ago

0.0.9

4 years ago

0.0.3-beta.6

4 years ago

0.0.8-beta.0

4 years ago

0.0.7

4 years ago

0.0.6-beta.0

4 years ago

0.0.6

4 years ago

0.0.3

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.1-beta.12

4 years ago

0.0.2

4 years ago

0.0.1-beta.2

4 years ago

0.0.3-beta.0

4 years ago

0.0.1-beta.14

4 years ago

0.0.1-beta.13

4 years ago

0.0.1-beta.1

4 years ago

0.0.1-beta.11

4 years ago

0.0.1-beta.10

4 years ago

0.0.1-beta.6

4 years ago

0.0.1-beta.5

4 years ago

0.0.1-beta.4

4 years ago

0.0.1-beta.3

4 years ago