diff --git a/README.md b/README.md index 68f04e220..73f5ccfda 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,6 @@ - [🤓 Resources](#-resources) - [🏄 Get Started](#-get-started) - [Local Spree components with Barge](#local-spree-components-with-barge) - - [API](#api) - [🦑 Environment variables](#-environment-variables) - [🎨 Storybook](#-storybook) - [✨ Code Style](#-code-style) @@ -73,12 +72,6 @@ Finally, set environment variables to use those local connections in `.env` in t cp .env.example .env ``` -### API - -Files under `/api` are isolated and not part of Gatsby. - -- [API Documentation](api/) - ## 🦑 Environment variables The `app.config.js` file is setup to prioritize environment variables for setting each Ocean component endpoint. By setting environment variables, you can easily switch between Ocean networks the app connects to, without directly modifying `app.config.js`. diff --git a/api/redeploy.ts b/api/redeploy.ts deleted file mode 100644 index 2c7b6aeeb..000000000 --- a/api/redeploy.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { NowRequest, NowResponse } from '@vercel/node' -import axios, { AxiosResponse } from 'axios' -import siteConfig from '../content/site.json' - -async function redeploy( - req: NowRequest -): Promise { - // Cancel if we are not on live - if (req.headers.host !== siteConfig.site.siteUrl) return '' - console.log('not canceled', req) - try { - // Trigger new `master` deployment with Deploy Hook - const newDeployment = await axios.post( - 'https://api.zeit.co/v1/integrations/deploy/Qmd5YCS9PCCCqn4mjgVR3vGkYWNmEB5UnAzhnjZiGbMCKa/Q6viwRoT4V' - ) - return newDeployment - } catch (error) { - console.error(error.message) - } -} - -export default async (req: NowRequest, res: NowResponse) => { - switch (req.method) { - case 'POST': - res.status(200).json(await redeploy(req)) - break - default: - res.setHeader('Allow', ['POST']) - res.status(405).end(`Method ${req.method} Not Allowed`) - } -} diff --git a/src/components/molecules/DeleteAsset.tsx b/src/components/molecules/DeleteAsset.tsx index 271d701ec..d890160e8 100644 --- a/src/components/molecules/DeleteAsset.tsx +++ b/src/components/molecules/DeleteAsset.tsx @@ -1,7 +1,6 @@ -import React, { useState, useEffect } from 'react' +import React, { useState, useEffect, ReactElement } from 'react' import { useNavigate } from '@reach/router' import { DDO } from '@oceanprotocol/lib' -import { redeploy } from '../../utils' import Button from '../atoms/Button' import BaseDialog from '../atoms/BaseDialog' import { useOcean } from '@oceanprotocol/react' @@ -13,7 +12,7 @@ const content = [ 'Something happened... Your Data Set cannot be deleted' ] -export default function DeleteAction({ ddo }: { ddo: DDO }) { +export default function DeleteAction({ ddo }: { ddo: DDO }): ReactElement { const { ocean, accountId } = useOcean() const navigate = useNavigate() const isOwner = ddo.publicKey[0].owner === accountId @@ -42,9 +41,6 @@ export default function DeleteAction({ ddo }: { ddo: DDO }) { const consumerAddress = (await ocean.accounts.list())[0] await ocean.assets.retire(ddo.id, consumerAddress) - // trigger new live deployment - await redeploy() - setStatus(2) } catch (error) { // TODO: handle error diff --git a/src/utils/index.ts b/src/utils/index.ts index e72d98885..895efb71f 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -139,12 +139,3 @@ export function formatBytes(a: number, b: number): string { const f = Math.floor(Math.log(a) / Math.log(c)) return parseFloat((a / Math.pow(c, f)).toFixed(d)) + ' ' + e[f] } - -export async function redeploy(): Promise { - try { - const response = await axios.post('/api/redeploy') - return response - } catch (err) { - console.error(err.message) - } -} diff --git a/tests/unit/api/file.test.tsx b/tests/unit/api/file.test.tsx deleted file mode 100644 index 6f463a9e6..000000000 --- a/tests/unit/api/file.test.tsx +++ /dev/null @@ -1,28 +0,0 @@ -import { createMocks } from 'node-mocks-http' -import apiRoute from '../../../api/file' - -describe('/api/file', () => { - test('responds 405 to GET', async () => { - const { req, res } = createMocks() - apiRoute(req, res) - expect(res._getStatusCode()).toBe(405) - }) - - test('responds 200 to POST', async () => { - const { req, res } = createMocks({ method: 'POST' }) - apiRoute(req, res) - expect(res._getStatusCode()).toBe(200) - }) - - test('responds correctly to POST and url passed in body', async () => { - const { req, res } = createMocks({ - method: 'POST', - body: { - url: 'https://oceanprotocol.com/tech-whitepaper.pdf' - } - }) - apiRoute(req, res) - expect(res._getStatusCode()).toBe(200) - expect(res._getData()).toBeDefined() - }) -}) diff --git a/tsconfig.json b/tsconfig.json index b1de2a998..fd6658238 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -16,5 +16,5 @@ "allowJs": true }, "exclude": ["node_modules", "public", ".cache", "*.js"], - "include": ["./src/**/*", "./api/**/*", "./tests/**/*", "./app.config.js"] + "include": ["./src/**/*", "./tests/**/*", "./app.config.js"] }