backend input validation

This commit is contained in:
Avraham Sakal
2024-02-04 21:50:22 -05:00
parent 63185f485f
commit 0627acc8cf
+10 -10
View File
@@ -46,7 +46,7 @@ const appRouter = router({
}), }),
getExpirationsForUnderlying: publicProcedure getExpirationsForUnderlying: publicProcedure
.input(RpcType(ObjectT({ .input(RpcType(ObjectT({
underlying:StringT(), underlying:StringT({maxLength:5}),
asOfDate:StringT() asOfDate:StringT()
}))) })))
.query(async (opts)=>{ .query(async (opts)=>{
@@ -62,7 +62,7 @@ const appRouter = router({
}), }),
getStrikesForUnderlying: publicProcedure getStrikesForUnderlying: publicProcedure
.input(RpcType(ObjectT({ .input(RpcType(ObjectT({
underlying:StringT(), underlying:StringT({maxLength:5}),
asOfDate:StringT(), asOfDate:StringT(),
expirationDate:StringT(), expirationDate:StringT(),
}))) })))
@@ -80,7 +80,7 @@ const appRouter = router({
}), }),
getOpensForUnderlying: publicProcedure getOpensForUnderlying: publicProcedure
.input(RpcType(ObjectT({ .input(RpcType(ObjectT({
underlying:StringT() underlying:StringT({maxLength:5})
}))) })))
.query(async (opts)=>{ .query(async (opts)=>{
const {underlying} = opts.input; const {underlying} = opts.input;
@@ -96,7 +96,7 @@ const appRouter = router({
}), }),
getOpensForOptionContract: publicProcedure getOpensForOptionContract: publicProcedure
.input(RpcType(ObjectT({ .input(RpcType(ObjectT({
underlying:StringT(), underlying:StringT({maxLength:5}),
expirationDate:StringT(), expirationDate:StringT(),
strike:NumberT() strike:NumberT()
}))) })))
@@ -117,7 +117,7 @@ const appRouter = router({
}), }),
getHistoricalCalendarPrices: publicProcedure getHistoricalCalendarPrices: publicProcedure
.input(RpcType(ObjectT({ .input(RpcType(ObjectT({
underlying:StringT(), underlying:StringT({maxLength:5}),
daysToFrontExpiration:NumberT(), daysToFrontExpiration:NumberT(),
daysBetweenFrontAndBackExpiration:NumberT(), daysBetweenFrontAndBackExpiration:NumberT(),
strikePercentageFromUnderlyingPriceRangeMin:NumberT(), strikePercentageFromUnderlyingPriceRangeMin:NumberT(),
@@ -140,7 +140,7 @@ const appRouter = router({
}), }),
getHistoricalStockQuoteChartData: publicProcedure getHistoricalStockQuoteChartData: publicProcedure
.input(RpcType(ObjectT({ .input(RpcType(ObjectT({
underlying:StringT(), underlying:StringT({maxLength:5}),
lookbackPeriodStart:StringT(), lookbackPeriodStart:StringT(),
lookbackPeriodEnd:StringT(), lookbackPeriodEnd:StringT(),
}))) })))
@@ -159,7 +159,7 @@ const appRouter = router({
}), }),
getHistoricalCalendarQuoteChartData: publicProcedure getHistoricalCalendarQuoteChartData: publicProcedure
.input(RpcType(ObjectT({ .input(RpcType(ObjectT({
underlying:StringT(), underlying:StringT({maxLength:5}),
daysToFrontExpiration:NumberT(), daysToFrontExpiration:NumberT(),
daysBetweenFrontAndBackExpiration:NumberT(), daysBetweenFrontAndBackExpiration:NumberT(),
strikePercentageFromUnderlyingPriceRangeMin:NumberT(), strikePercentageFromUnderlyingPriceRangeMin:NumberT(),
@@ -185,11 +185,11 @@ const appRouter = router({
}), }),
getHistoricalCalendarExitQuoteChartData: publicProcedure getHistoricalCalendarExitQuoteChartData: publicProcedure
.input(RpcType(ObjectT({ .input(RpcType(ObjectT({
underlying:StringT(), underlying:StringT({maxLength:5}),
daysToFrontExpiration:NumberT(), daysToFrontExpiration:NumberT(),
daysBetweenFrontAndBackExpiration:NumberT(), daysBetweenFrontAndBackExpiration:NumberT(),
lookbackPeriodStart:StringT(), lookbackPeriodStart:StringT({pattern:'[0-9]{4}\-[0-9]{2}\-[0-9]{2}'}),
lookbackPeriodEnd:StringT(), lookbackPeriodEnd:StringT({pattern:'[0-9]{4}\-[0-9]{2}\-[0-9]{2}'}),
}))) })))
.query(async (opts)=>{ .query(async (opts)=>{
const {underlying, daysToFrontExpiration, daysBetweenFrontAndBackExpiration, lookbackPeriodStart, lookbackPeriodEnd, } = opts.input; const {underlying, daysToFrontExpiration, daysBetweenFrontAndBackExpiration, lookbackPeriodStart, lookbackPeriodEnd, } = opts.input;