mirror of
https://github.com/stronk-dev/RandomChad.git
synced 2025-07-05 10:35:08 +02:00
API abuse protection
This commit is contained in:
parent
41c806dc29
commit
a5c8a060d7
@ -24,4 +24,4 @@ The Rocketeer viewer hosted at [viewer.rocketeer.fans]( https://viewer.rocketeer
|
||||
|
||||
### Oracle code
|
||||
|
||||
The metadata and image oracle generates the Rocketeer data when one is minted. The code is inside the `functions` folder.
|
||||
The metadata and image oracle generates the Rocketeer data when one is minted. The code is inside the `functions` folder.
|
||||
|
@ -10,9 +10,13 @@ const { setAvatar, resetAvatar } = require( '../integrations/avatar' )
|
||||
app.get( '/api/rocketeer/:id', async ( req, res ) => {
|
||||
|
||||
// Parse the request
|
||||
const { id } = req.params
|
||||
let { id } = req.params
|
||||
if( !id ) return res.json( { error: `No ID specified in URL` } )
|
||||
|
||||
// Protect against malformed input
|
||||
id = Math.floor( Math.abs( id ) )
|
||||
if( typeof id !== 'number' ) return res.json( { error: `Malformed request` } )
|
||||
|
||||
try {
|
||||
|
||||
// Get old rocketeer if it exists
|
||||
|
@ -8,9 +8,13 @@ const { safelyReturnRocketeer, web2domain } = require( './rocketeer' )
|
||||
app.get( '/testnetapi/rocketeer/:id', async ( req, res ) => {
|
||||
|
||||
// Parse the request
|
||||
const { id } = req.params
|
||||
let { id } = req.params
|
||||
if( !id ) return res.json( { error: `No ID specified in URL` } )
|
||||
|
||||
// Protect against malformed input
|
||||
id = Math.floor( Math.abs( id ) )
|
||||
if( typeof id !== 'number' ) return res.json( { error: `Malformed request` } )
|
||||
|
||||
try {
|
||||
|
||||
// Get old rocketeer if it exists
|
||||
|
Loading…
x
Reference in New Issue
Block a user