0.0.17 • Published 3 years ago

@something.technology/microservice-utilities v0.0.17

Weekly downloads
301
License
MIT
Repository
-
Last release
3 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

3 years ago

0.0.16

3 years ago

0.0.15-beta.0

3 years ago

0.0.15

3 years ago

0.0.14

3 years ago

0.0.13

3 years ago

0.0.12

3 years ago

0.0.10

3 years ago

0.0.11

3 years ago

0.0.9-beta.0

3 years ago

0.0.9

3 years ago

0.0.3-beta.6

3 years ago

0.0.8-beta.0

3 years ago

0.0.7

3 years ago

0.0.6-beta.0

3 years ago

0.0.6

3 years ago

0.0.3

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.1-beta.12

3 years ago

0.0.2

3 years ago

0.0.1-beta.2

3 years ago

0.0.3-beta.0

3 years ago

0.0.1-beta.14

3 years ago

0.0.1-beta.13

3 years ago

0.0.1-beta.1

3 years ago

0.0.1-beta.11

3 years ago

0.0.1-beta.10

3 years ago

0.0.1-beta.6

3 years ago

0.0.1-beta.5

3 years ago

0.0.1-beta.4

3 years ago

0.0.1-beta.3

3 years ago