chore: retire packages endpoint

This commit is contained in:
Wojtek Rybakiewicz
2023-10-27 13:24:15 +02:00
parent b10088cb54
commit a5ed5f408a
2 changed files with 10 additions and 10 deletions

View File

@@ -15,3 +15,9 @@ export const configs = (router: Router) => {
res.json(tokensConfigResponse.data);
});
};
export function throwExpiredApiError() {
throw new Error(
'This API is expired. You can switch to redstone-sdk https://www.npmjs.com/package/redstone-sdk. If this API is necessary for your application - send us an email: dev@redstone.finance and set endpoint redstone.setCacheApiUrl("https://expiring.b.redstone.finance/prices") which will be also expired in few days.'
);
}

View File

@@ -4,9 +4,10 @@ import { Package } from "../models/package";
import { Price } from "../models/price";
import { getProviderFromParams } from "../utils";
import { tryCleanCollection } from "../helpers/mongo";
import { enableLiteMode, cacheTTLMilliseconds } from "../config";
import { enableLiteMode, cacheTTLMilliseconds, } from "../config";
import { Router } from "express";
import { Document } from "mongoose";
import {throwExpiredApiError} from "./configs"
const dbItemToObj = (item: Document<unknown, any, Package> & Package) => {
return _.omit(item.toObject(), ["_id", "__v"]);
@@ -95,8 +96,7 @@ export const packages = (router: Router) => {
"/packages/latest",
asyncHandler(async (req, res) => {
console.log("Getting latest packages")
const initialMongoQuery = {};
return await findPackage(req, res, initialMongoQuery);
throwExpiredApiError()
})
);
@@ -107,14 +107,8 @@ export const packages = (router: Router) => {
router.get(
"/packages",
asyncHandler(async (req, res) => {
if (!req.query.toTimestamp) {
throw new Error("toTimestamp query param is required");
}
console.log("Getting packages by timestamp")
const initialMongoQuery = {
timestamp: { $lte: req.query.toTimestamp },
};
return await findPackage(req, res, initialMongoQuery);
throwExpiredApiError()
})
);
};