diff --git a/firebase.json b/firebase.json index 0990645..5f34f85 100644 --- a/firebase.json +++ b/firebase.json @@ -13,10 +13,6 @@ "target": "website", "public": "website/docs", "rewrites": [ - { - "source": "/api/integrations/avatar", - "function": "setAvatarOfValidtor" - }, { "source": "/api/**", "function": "mainnetMetadata" diff --git a/functions/index.js b/functions/index.js index e6f0948..8e42059 100644 --- a/functions/index.js +++ b/functions/index.js @@ -1,7 +1,6 @@ const functions = require( 'firebase-functions' ) const testnetAPI = require( './modules/testnet' ) const mainnetAPI = require( './modules/mainnet' ) -const setAvatarOfValidtor = require( './integrations/avatar' ) // Runtime config const runtime = { @@ -13,9 +12,4 @@ const runtime = { exports.testnetMetadata = functions.runWith( runtime ).https.onRequest( testnetAPI ) // Mainnet endpoint -exports.mainnetMetadata = functions.runWith( runtime ).https.onRequest( mainnetAPI ) - -/* /////////////////////////////// -// Integrations -// /////////////////////////////*/ -exports.setAvatarOfValidtor = functions.https.onRequest( setAvatarOfValidtor ) \ No newline at end of file +exports.mainnetMetadata = functions.runWith( runtime ).https.onRequest( mainnetAPI ) \ No newline at end of file diff --git a/functions/integrations/avatar.js b/functions/integrations/avatar.js index bcf0fcb..18f9083 100644 --- a/functions/integrations/avatar.js +++ b/functions/integrations/avatar.js @@ -70,7 +70,7 @@ module.exports = async function( req, res ) { console.log( 'New data: ', cachedJson ) - return res.send( { + return res.json( { success: true, url: cacheFile.publicUrl() } ) @@ -78,7 +78,7 @@ module.exports = async function( req, res ) { } catch( e ) { console.error( 'avatar integration error: ', e ) - return res.send( { + return res.json( { error: e.message } ) diff --git a/functions/modules/mainnet.js b/functions/modules/mainnet.js index af6324a..0d18207 100644 --- a/functions/modules/mainnet.js +++ b/functions/modules/mainnet.js @@ -1,6 +1,7 @@ const app = require( './express' )() const { getTotalSupply } = require( './contract' ) const { safelyReturnRocketeer, web2domain } = require( './rocketeer' ) +const setAvatarOfValidtor = require( '../integrations/avatar' ) // /////////////////////////////// @@ -32,6 +33,8 @@ app.get( '/api/rocketeer/:id', async ( req, res ) => { } ) +app.post( '/api/integrations/', setAvatarOfValidtor ) + // /////////////////////////////// // Static collection data