mirror of
https://github.com/alexgo-io/redstone-cache-layer.git
synced 2026-05-01 05:02:05 +08:00
chore: retire packages endpoint
This commit is contained in:
@@ -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.'
|
||||
);
|
||||
}
|
||||
@@ -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()
|
||||
})
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user