Skip to content

Commit 6a5f4a2

Browse files
committed
migrate to TypeScript only features
1 parent ee4cb45 commit 6a5f4a2

File tree

6 files changed

+19
-20
lines changed

6 files changed

+19
-20
lines changed

src/modules/services.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ import { LogsRepository, TickerLogRepository, TickerRepository } from '../reposi
3535
import { QueueManager } from '../utils/queue';
3636
import { FileCache } from '../utils/file_cache';
3737
import { BinancePriceService } from '../utils/binance_price_service';
38+
import nodemailer from 'nodemailer';
39+
import { Telegraf } from 'telegraf';
3840

3941
import { ExchangeCandleCombine } from './exchange/exchange_candle_combine';
4042
import { ExchangeInstanceService } from './system/exchange_instance_service';
@@ -429,11 +431,9 @@ const services: Services = {
429431
},
430432

431433
createMailer: function (): any {
432-
const mail = require('nodemailer');
433-
434434
const config = this.getConfig();
435435

436-
return mail.createTransport({
436+
return nodemailer.createTransport({
437437
host: config.notify?.mail?.server,
438438
port: config.notify?.mail?.port,
439439
secure: config.notify?.mail?.port == 465,
@@ -445,7 +445,6 @@ const services: Services = {
445445
},
446446

447447
createTelegram: function (): any {
448-
const { Telegraf } = require('telegraf');
449448
const config = this.getConfig();
450449
const { token } = config.notify?.telegram || {};
451450

src/utils/indicators.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ interface TalibModule {
6565
execute: (params: Record<string, unknown>) => TalibResult;
6666
}
6767

68-
// Lazy load modules
68+
// Lazy load modules (using dynamic import for heavy native modules)
6969
const getTalib = (): TalibModule => require('talib');
70-
const getTechnicalIndicators = (): typeof import('technicalindicators') => require('technicalindicators');
70+
const getTechnicalIndicators = () => require('technicalindicators') as typeof import('technicalindicators');
7171

7272
interface PivotPointsWithWicksResult {
7373
high?: { close?: number; high?: number };

src/utils/queue.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const Queue = require('queue-promise');
1+
import Queue from 'queue-promise';
22

33
export class QueueManager {
44
private queue: any;
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const assert = require('assert');
2-
const fs = require('fs');
1+
import assert from 'assert';
2+
import fs from 'fs';
33

44
describe('#validate pre deployment files', function() {
55
it('test that config.json.dist file is valid', () => {
@@ -12,6 +12,6 @@ describe('#validate pre deployment files', function() {
1212
const instances = require(`${__dirname}/../instance.js.dist`);
1313

1414
assert.equal(instances.symbols.length > 0, true);
15-
assert.equal(instances.symbols.filter(i => i.symbol === 'ETHUSD').length, 1);
15+
assert.equal(instances.symbols.filter((i: any) => i.symbol === 'ETHUSD').length, 1);
1616
});
1717
});
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
const assert = require('assert');
2-
const moment = require('moment');
3-
const { Tickers } = require('../../src/storage/tickers');
4-
const { Ticker } = require('../../src/dict/ticker');
1+
import assert from 'assert';
2+
import moment from 'moment';
3+
import { Tickers } from '../../src/storage/tickers';
4+
import { Ticker } from '../../src/dict/ticker';
55

66
describe('#tickers', function() {
77
it('test getting update tickers', () => {
@@ -13,9 +13,9 @@ describe('#tickers', function() {
1313
.subtract(5000, 'ms')
1414
.toDate();
1515

16-
assert.equal(tickers.get('foobar', 'BTCUSD').ask, 1338);
16+
assert.equal(tickers.get('foobar', 'BTCUSD')?.ask, 1338);
1717
assert.equal(tickers.getIfUpToDate('foobar', 'BTCUSD', 1000), undefined);
1818

19-
assert.equal(tickers.getIfUpToDate('foobar', 'BTCUSD', 7000).ask, 1338);
19+
assert.equal(tickers.getIfUpToDate('foobar', 'BTCUSD', 7000)?.ask, 1338);
2020
});
2121
});
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
const assert = require('assert');
2-
const fs = require('fs');
3-
const path = require('path');
4-
const { ConfigService } = require('../../src/modules/system/config_service');
1+
import assert from 'assert';
2+
import fs from 'fs';
3+
import path from 'path';
4+
import { ConfigService } from '../../src/modules/system/config_service';
55

66
describe('#config service test', function() {
77
const testConfigDir = path.join(__dirname, 'fixtures');

0 commit comments

Comments
 (0)