Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@skbkontur/node-core

Package Overview
Dependencies
Maintainers
5
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@skbkontur/node-core - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0-rc.1

13

doc/config.md

@@ -8,4 +8,2 @@

`config.zone` - Зона кластер конфига
`config.hostName` - hostName текущего приложения. Необходим для отправки в различные системы

@@ -34,2 +32,4 @@

`options.defaultLoggerTransport` - `{Boolean} default: false` Флаг для отключения транспортов по умолчанию для логгера.
`options.prefixSpanAggrHostname` - `{String} default: 'portal/nodeapp/SpanAggrHostname'` Префикс настройки кластер конфига для настройки инстанса спан агрегатора.

@@ -44,3 +44,2 @@

const {
zone: '...',
hostName: '...',

@@ -61,2 +60,3 @@ appName: '...',

errorHandling: true,
defaultLoggerTransport: true,
prefixSpanAggrHostname: 'portal/nodeapp/SpanAggrHostname',

@@ -73,6 +73,7 @@ prefixSpanAggrProtocol: 'portal/nodeapp/SpanAggrProtocol',

```javascript
const coreAppInitialization = core.runApp(process, config)
coreAppInitialization
.then((coreApp) => {
core.initClusterConfig(config.zone)
.then(async (clusterConfig) => {
const coreApp = await core.runApp(config, clusterConfig);
const { logger } = coreApp

@@ -79,0 +80,0 @@ logger.configure({

@@ -8,3 +8,3 @@ # Что такое трассировки и как их включить у себя в приложении

```javascript
const coreApp = core.runApp(process, config, {
const coreApp = core.runApp(config, clusterConfig, {
tracing: true

@@ -11,0 +11,0 @@ })

@@ -16,6 +16,6 @@ // @flow

const clusterClient = require('@skbkontur/cluster-client')
const clusterConfigClient = require('@skbkontur/cluster-config-client')
const monitoringClient = require('@skbkontur/monitoring-client')
const spanAggregatorClient = require('@skbkontur/span-aggregator-client')
const winstonKonturLogstash = require('@skbkontur/winston-kontur-logstash')
const ClusterConfigClient = require('@skbkontur/cluster-config-client')
const MonitoringClient = require('@skbkontur/monitoring-client')
const SpanAggregatorClient = require('@skbkontur/span-aggregator-client')

@@ -47,2 +47,3 @@ const types = require('./types')

errorHandling: true,
defaultLoggerTransport: true,
prefixSpanAggrHostname: 'portal/nodeapp/SpanAggrHostname',

@@ -53,3 +54,3 @@ prefixSpanAggrProtocol: 'portal/nodeapp/SpanAggrProtocol',

async function runApp(process /* : Process */, config /* : Config */, options /* : UserOptions */) {
async function runApp(config /* : Config */, clusterConfig /* : ClusterConfigClient */, options /* : UserOptions */) {
const opts = Object.assign({}, defaultOptions, options)

@@ -69,3 +70,3 @@ let logger = console

const coreComponents = await initComponents(config, opts)
const coreComponents = await initComponents(config, clusterConfig, opts)
logger = coreComponents.logger

@@ -76,5 +77,13 @@

async function initClusterConfig(zone /* : string */) /* : Promise<ClusterConfigClient> */ {
const clusterConfig = new ClusterConfigClient({ zone })
await clusterConfig.waitForInitialization()
return clusterConfig
}
module.exports = {
providers,
useCore,
initClusterConfig,
runApp,

@@ -85,7 +94,7 @@ types,

clusterClient,
clusterConfigClient,
monitoringClient,
spanAggregatorClient,
ClusterConfigClient,
MonitoringClient,
SpanAggregatorClient,
winstonKonturLogstash
}
}
// @flow
/* ::
import type { Options, Config } from './types'
import type { Options, Config } from './types';
import ClusterConfigClient from '@skbkontur/cluster-config-client';
*/

@@ -9,3 +11,2 @@

const ClusterConfigClient = require('@skbkontur/cluster-config-client')
const SpanAggregator = require('@skbkontur/span-aggregator-client')

@@ -60,22 +61,5 @@

async function initComponents(config /* : Config */, options /* : Options */) {
const {
zone,
id,
appName,
loggerServerName,
loggerIndexPrefix,
loggerApiKey
} = config
async function initComponents(config /* : Config */, clusterConfig /* : ClusterConfigClient */, options /* : Options */) {
const logger = loggerModule.createLogger(config, options)
const logger = loggerModule.createLogger({
type: `${appName}.Node.${id}`,
serverName: loggerServerName,
path: `/logs/${loggerIndexPrefix}-{date}`,
apiKey: `ELK ${loggerApiKey}`
})
const clusterConfig = new ClusterConfigClient({ zone })
await clusterConfig.waitForInitialization()
const { monitoringClient, monitor } = await runMonitoring(config, options, clusterConfig)

@@ -86,3 +70,2 @@ const spanAggregator = await createSpanAggr(config, options, clusterConfig)

logger,
clusterConfig,
monitor,

@@ -89,0 +72,0 @@ monitoringClient,

@@ -11,3 +11,3 @@ // @flow

import type { ILogger } from '../types';
import type { ILogger, Config, Options } from '../types';
*/

@@ -38,9 +38,28 @@

function createLogger(options /* : loggerOptions */) /* : ILogger */ {
function createLogger(config /* : Config */, options /* : Options */) /* : ILogger */ {
const {
id,
appName,
loggerServerName,
loggerIndexPrefix,
loggerApiKey
} = config
const ELKOptions = {
type: `${appName}.Node.${id}`,
serverName: loggerServerName,
path: `/logs/${loggerIndexPrefix}-{date}`,
apiKey: `ELK ${loggerApiKey}`
}
const defaultTransports = [
new KonturLogstash(ELKOptions),
new winston.transports.Console({ colorize: true })
]
const transports = options.defaultLoggerTransport ? defaultTransports : []
logger = new winston.Logger({
levels: KONTUR_LOGGER_LEVELS,
transports: [
new KonturLogstash(options),
new winston.transports.Console({ colorize: true })
]
transports
})

@@ -47,0 +66,0 @@ winston.addColors(KONTUR_LOGGER_COLORS)

@@ -5,3 +5,2 @@ // @flow

export type Config = {
zone: string,
id: string,

@@ -33,2 +32,3 @@ appName: string,

errorHandling: bool,
defaultLoggerTransport: bool,
prefixSpanAggrHostname: string,

@@ -35,0 +35,0 @@ prefixSpanAggrProtocol: string,

{
"name": "@skbkontur/node-core",
"version": "1.1.0",
"version": "1.2.0-rc.1",
"description": "Основные компоненты для разработки на Node.js",

@@ -35,8 +35,2 @@ "main": "./lib/index.js",

],
"globals": {
"it": true,
"jest": true,
"expect": true,
"test": true
},
"rules": {

@@ -43,0 +37,0 @@ "space-before-function-paren": [

@@ -34,16 +34,16 @@ # Быстрый старт Node.js приложений на инфраструктуре Контура

const coreApp = core.runApp(process, config)
core.initClusterConfig(config.zone)
.then((clusterConfig) => core.runApp(config, clusterConfig))
.then(async function createApp(coreApp) {
const { logger } = coreApp
coreApp.then(async function createApp(coreApp) {
const { logger } = coreApp
core.useCore(app, coreApp)
core.useCore(app, coreApp)
app.use(auth)
app.use(router())
app.use(auth)
app.use(router())
app.listen(config.port, () => {
logger.info(`Application started at http://localhost:${config.port}`)
app.listen(config.port, () => {
logger.info(`Application started at http://localhost:${config.port}`)
})
})
})
```

@@ -50,0 +50,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc