2.0.24 • Published 5 years ago

connect-utilities v2.0.24

Weekly downloads
-
License
ISC
Repository
bitbucket
Last release
5 years ago

Connect Utilities

Common connect utilities, services and middlesares used by all microservices.

Usage

const connectUtils = require('connect-utilities');

// Logger
global.logger = connectUtils.logger.initializeLogger({ packageJsonPath: __dirname + '../../package.json' });


// Express Middlewares
const {
    errorHandlerMiddleware,
    inputValidationMiddleware,
    routeLoggerMiddleware
} = connectUtils.middlewares;

// pubsub
const {
    Publisher,
    Subscriber
} = connectUtils.pubsub;

// first arg is logger
app.use(errorHandlerMiddleware(global.logger))

// first arg is logger
app.use(routeLoggerMiddleware(global.logger))

//sequelize

const { initializeSequelize } = require('connect-utilities').sequelize;

global.models = await initializeSequelize({
    connectionString: global.config.DB_CONNECTION_STRING,
    modelsPath: path.join(__dirname, '/models') //should be absolute path
    logger: global.logger //defaults to console if not specified
  });

// ConfigRetriever

global.configRetriever = new ConfigRetrieverMiddleware(global.models.UserFieldConfiguration);

publicRouter.use('/admin', global.configRetriever.getMiddlewares(), require('./routes/admin.route'));

`req.serviceConfig` is exposed
2.0.24

5 years ago

2.0.23

5 years ago

2.0.22

5 years ago

2.0.21

5 years ago

2.0.20

5 years ago

2.0.19

5 years ago

2.0.18

5 years ago

2.0.17

5 years ago

2.0.16

5 years ago

2.0.15

5 years ago

2.0.14

5 years ago

2.0.12

5 years ago

2.0.11

5 years ago

2.0.9

5 years ago

2.0.10

5 years ago

2.0.7

5 years ago

2.0.6

5 years ago

2.0.5

5 years ago

2.0.4

5 years ago

2.0.3

5 years ago

2.0.2

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.0.29

5 years ago

1.0.27

5 years ago

1.0.26

5 years ago

1.0.25

5 years ago

1.0.24

5 years ago

1.0.23

5 years ago

1.0.22

5 years ago

1.0.21

5 years ago

1.0.20

5 years ago

1.0.19

5 years ago

1.0.18

5 years ago

1.0.17

5 years ago

1.0.16

5 years ago

1.0.15

5 years ago

1.0.13

5 years ago

1.0.12

5 years ago

1.0.11

5 years ago

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago