mirror of
https://github.com/mempool/mempool.git
synced 2024-11-19 18:03:00 +01:00
add /prices api endpoint
This commit is contained in:
parent
cac2a984ab
commit
22665f149b
19
backend/src/api/prices/prices.routes.ts
Normal file
19
backend/src/api/prices/prices.routes.ts
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import { Application, Request, Response } from 'express';
|
||||||
|
import config from '../../config';
|
||||||
|
import pricesUpdater from '../../tasks/price-updater';
|
||||||
|
|
||||||
|
class PricesRoutes {
|
||||||
|
public initRoutes(app: Application): void {
|
||||||
|
app.get(config.MEMPOOL.API_URL_PREFIX + 'prices', this.$getCurrentPrices.bind(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
private async $getCurrentPrices(req: Request, res: Response): Promise<void> {
|
||||||
|
res.header('Pragma', 'public');
|
||||||
|
res.header('Cache-control', 'public');
|
||||||
|
res.setHeader('Expires', new Date(Date.now() + 1000 * 300).toUTCString());
|
||||||
|
|
||||||
|
res.json(pricesUpdater.getLatestPrices());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default new PricesRoutes();
|
@ -30,6 +30,7 @@ import generalLightningRoutes from './api/explorer/general.routes';
|
|||||||
import lightningStatsUpdater from './tasks/lightning/stats-updater.service';
|
import lightningStatsUpdater from './tasks/lightning/stats-updater.service';
|
||||||
import networkSyncService from './tasks/lightning/network-sync.service';
|
import networkSyncService from './tasks/lightning/network-sync.service';
|
||||||
import statisticsRoutes from './api/statistics/statistics.routes';
|
import statisticsRoutes from './api/statistics/statistics.routes';
|
||||||
|
import pricesRoutes from './api/prices/prices.routes';
|
||||||
import miningRoutes from './api/mining/mining-routes';
|
import miningRoutes from './api/mining/mining-routes';
|
||||||
import bisqRoutes from './api/bisq/bisq.routes';
|
import bisqRoutes from './api/bisq/bisq.routes';
|
||||||
import liquidRoutes from './api/liquid/liquid.routes';
|
import liquidRoutes from './api/liquid/liquid.routes';
|
||||||
@ -261,6 +262,7 @@ class Server {
|
|||||||
|
|
||||||
setUpHttpApiRoutes(): void {
|
setUpHttpApiRoutes(): void {
|
||||||
bitcoinRoutes.initRoutes(this.app);
|
bitcoinRoutes.initRoutes(this.app);
|
||||||
|
pricesRoutes.initRoutes(this.app);
|
||||||
if (config.STATISTICS.ENABLED && config.DATABASE.ENABLED && config.MEMPOOL.ENABLED) {
|
if (config.STATISTICS.ENABLED && config.DATABASE.ENABLED && config.MEMPOOL.ENABLED) {
|
||||||
statisticsRoutes.initRoutes(this.app);
|
statisticsRoutes.initRoutes(this.app);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user