• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

decentraland / transactions-server / 4546632114

pending completion
4546632114

push

github

GitHub
Merge pull request #104 from decentraland/fix/add-tracer-to-logger

60 of 83 branches covered (72.29%)

Branch coverage included in aggregate %.

1 of 1 new or added line in 1 file covered. (100.0%)

289 of 411 relevant lines covered (70.32%)

3.45 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/components.ts
1
import path from 'path'
×
2
import { createDotEnvConfigComponent } from '@well-known-components/env-config-provider'
×
3
import {
×
4
  createServerComponent,
5
  createStatusCheckComponent,
6
} from '@well-known-components/http-server'
7
import { createTracerComponent } from '@well-known-components/tracer-component'
×
8
import { createLogComponent } from '@well-known-components/logger'
×
9
import { createMetricsComponent } from '@well-known-components/metrics'
×
10
import { createSubgraphComponent } from '@well-known-components/thegraph-component'
×
11
import { createHttpTracerComponent } from '@well-known-components/http-tracer-component'
×
12
import {
×
13
  instrumentHttpServerWithRequestLogger,
14
  Verbosity,
15
} from '@well-known-components/http-requests-logger-component'
16
import { createPgComponent } from '@well-known-components/pg-component'
×
17
import { createContractsComponent } from './ports/contracts/component'
×
18
import { createFetchComponent } from './ports/fetcher'
×
19
import { createFeaturesComponent } from './ports/features'
×
20
import { createTransactionComponent } from './ports/transaction/component'
×
21
import { metricDeclarations } from './metrics'
×
22
import { AppComponents, GlobalContext } from './types'
23

24
export async function initComponents(): Promise<AppComponents> {
×
25
  // default config from process.env + .env file
26
  const config = await createDotEnvConfigComponent(
×
27
    { path: ['.env.defaults', '.env'] },
28
    process.env
29
  )
30

31
  const cors = {
×
32
    origin: await config.getString('CORS_ORIGIN'),
33
    method: await config.getString('CORS_METHOD'),
34
  }
35

36
  const tracer = createTracerComponent()
×
37

38
  const logs = await createLogComponent({ config, tracer })
×
39
  const server = await createServerComponent<GlobalContext>(
×
40
    { config, logs },
41
    { cors, compression: {} }
42
  )
43
  createHttpTracerComponent({ server, tracer })
×
44
  instrumentHttpServerWithRequestLogger(
×
45
    { server, logger: logs },
46
    { verbosity: Verbosity.INFO }
47
  )
48
  const statusChecks = await createStatusCheckComponent({ config, server })
×
49
  const fetcher = await createFetchComponent({ tracer })
×
50
  const features = await createFeaturesComponent(
×
51
    {
52
      config,
53
      logs,
54
      fetch: fetcher,
55
    },
56
    await config.requireString('TRANSACTIONS_SERVER_URL')
57
  )
58
  const metrics = await createMetricsComponent(metricDeclarations, {
×
59
    server,
60
    config,
61
  })
62

63
  let databaseUrl: string | undefined = await config.getString(
×
64
    'PG_COMPONENT_PSQL_CONNECTION_STRING'
65
  )
66

67
  if (!databaseUrl) {
×
68
    const dbUser = await config.requireString('PG_COMPONENT_PSQL_USER')
×
69
    const dbDatabaseName = await config.requireString(
×
70
      'PG_COMPONENT_PSQL_DATABASE'
71
    )
72
    const dbPort = await config.requireString('PG_COMPONENT_PSQL_PORT')
×
73
    const dbHost = await config.requireString('PG_COMPONENT_PSQL_HOST')
×
74
    const dbPassword = await config.requireString('PG_COMPONENT_PSQL_PASSWORD')
×
75
    databaseUrl = `postgres://${dbUser}:${dbPassword}@${dbHost}:${dbPort}/${dbDatabaseName}`
×
76
  }
77

78
  const pg = await createPgComponent(
×
79
    { logs, config, metrics },
80
    {
81
      migration: {
82
        databaseUrl,
83
        dir: path.resolve(__dirname, 'migrations'),
84
        migrationsTable: 'pgmigrations',
85
        ignorePattern: '.*\\.map',
86
        direction: 'up',
87
      },
88
    }
89
  )
90
  const collectionsSubgraph = await createSubgraphComponent(
×
91
    { config, logs, fetch: fetcher, metrics },
92
    await config.requireString('COLLECTIONS_SUBGRAPH_URL')
93
  )
94

95
  const contracts = createContractsComponent({
×
96
    config,
97
    fetcher,
98
    collectionsSubgraph,
99
  })
100

101
  const transaction = createTransactionComponent({
×
102
    config,
103
    features,
104
    fetcher,
105
    logs,
106
    pg,
107
    contracts,
108
    metrics,
109
  })
110
  const globalLogger = logs.getLogger('transactions-server')
×
111

112
  return {
×
113
    config,
114
    logs,
115
    globalLogger,
116
    fetcher,
117
    features,
118
    metrics,
119
    server,
120
    pg,
121
    transaction,
122
    contracts,
123
    collectionsSubgraph,
124
    statusChecks,
125
  }
126
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc