Send correct content-types.

This commit is contained in:
softsimon 2020-07-18 18:46:33 +07:00
parent 66c565a3d7
commit 5198c3a5af
No known key found for this signature in database
GPG Key ID: 488D7DCFB5A430D7
2 changed files with 19 additions and 18 deletions

View File

@ -26,42 +26,42 @@ class Routes {
public async get2HStatistics(req: Request, res: Response) {
const result = await statistics.$list2H();
res.send(result);
res.json(result);
}
public get24HStatistics(req: Request, res: Response) {
res.send(this.cache['24h']);
res.json(this.cache['24h']);
}
public get1WHStatistics(req: Request, res: Response) {
res.send(this.cache['1w']);
res.json(this.cache['1w']);
}
public get1MStatistics(req: Request, res: Response) {
res.send(this.cache['1m']);
res.json(this.cache['1m']);
}
public get3MStatistics(req: Request, res: Response) {
res.send(this.cache['3m']);
res.json(this.cache['3m']);
}
public get6MStatistics(req: Request, res: Response) {
res.send(this.cache['6m']);
res.json(this.cache['6m']);
}
public get1YStatistics(req: Request, res: Response) {
res.send(this.cache['1y']);
res.json(this.cache['1y']);
}
public async getRecommendedFees(req: Request, res: Response) {
const result = feeApi.getRecommendedFee();
res.send(result);
res.json(result);
}
public getMempoolBlocks(req: Request, res: Response) {
try {
const result = mempoolBlocks.getMempoolBlocks();
res.send(result);
res.json(result);
} catch (e) {
res.status(500).send(e.message);
}
@ -80,27 +80,28 @@ class Routes {
}
const times = mempool.getFirstSeenForTransactions(txIds);
res.send(times);
res.json(times);
}
public getBackendInfo(req: Request, res: Response) {
res.send(backendInfo.getBackendInfo());
res.json(backendInfo.getBackendInfo());
}
public getBisqStats(req: Request, res: Response) {
const result = bisq.getStats();
res.send(result);
res.json(result);
}
public getBisqTip(req: Request, res: Response) {
const result = bisq.getLatestBlockHeight();
res.type('text/plain');
res.send(result.toString());
}
public getBisqTransaction(req: Request, res: Response) {
const result = bisq.getTransaction(req.params.txId);
if (result) {
res.send(result);
res.json(result);
} else {
res.status(404).send('Bisq transaction not found');
}
@ -111,13 +112,13 @@ class Routes {
const length = parseInt(req.params.length, 10) > 100 ? 100 : parseInt(req.params.length, 10) || 25;
const [transactions, count] = bisq.getTransactions(index, length);
res.header('X-Total-Count', count.toString());
res.send(transactions);
res.json(transactions);
}
public getBisqBlock(req: Request, res: Response) {
const result = bisq.getBlock(req.params.hash);
if (result) {
res.send(result);
res.json(result);
} else {
res.status(404).send('Bisq block not found');
}
@ -128,13 +129,13 @@ class Routes {
const length = parseInt(req.params.length, 10) > 100 ? 100 : parseInt(req.params.length, 10) || 25;
const [transactions, count] = bisq.getBlocks(index, length);
res.header('X-Total-Count', count.toString());
res.send(transactions);
res.json(transactions);
}
public getBisqAddress(req: Request, res: Response) {
const result = bisq.getAddress(req.params.address.substr(1));
if (result) {
res.send(result);
res.json(result);
} else {
res.status(404).send('Bisq address not found');
}

View File

@ -25,7 +25,7 @@ export class AboutComponent implements OnInit {
if (this.stateService.network === 'bisq') {
this.active = 2;
}
if (document.location.port !== '443') {
if (document.location.port !== '') {
this.hostname = this.hostname + ':' + document.location.port;
}
}