-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IPFS api #37
IPFS api #37
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
REACT_APP_IPFS_URL="http://109.235.70.27:5001" | ||
REACT_APP_TENSORFLOW_URL="http://109.235.70.27:8501" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
REACT_APP_TENSORFLOW_URL="" | ||
REACT_APP_IPFS_URL="http://localhost:3000/IPFS_API" | ||
REACT_APP_TENSORFLOW_URL="http://localhost:3000/TF_API" |
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ import LoadingScreen from './components/LoadingScreen'; | |
// universaldot imports | ||
import { useProfile, useUser, useLoader } from './hooks/universaldot'; | ||
import { useSubstrateState } from './substrate-lib'; | ||
import { useIpfsAPI } from './api'; | ||
// ---------------------------------------------------------------------- | ||
|
||
export default function App() { | ||
|
@@ -41,6 +42,17 @@ export default function App() { | |
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, [keyring]); | ||
|
||
const ipfsAPI = useIpfsAPI(); | ||
|
||
useEffect(() => { | ||
const fetchIpfsID = async () => { | ||
const result = await ipfsAPI.id(); | ||
console.log('IPFS id: ', result); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This returns and object with:
|
||
}; | ||
|
||
fetchIpfsID(); | ||
}, [ipfsAPI]); | ||
|
||
return ( | ||
<MotionLazyContainer> | ||
<ThemeProvider> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from './ipfs'; | ||
export * from './tensorFlow'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import windowInstance from '../window'; | ||
import { create } from 'ipfs-http-client'; | ||
import { useState } from 'react'; | ||
|
||
const { IPFS_URL } = windowInstance.env; | ||
const VERSION_PATH = '/api/v0'; | ||
|
||
export const useIpfsAPI = () => { | ||
const [ipfsAPI] = useState(() => create({ url: `${IPFS_URL}${VERSION_PATH}` })); | ||
|
||
return ipfsAPI; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
const { createProxyMiddleware } = require('http-proxy-middleware'); | ||
|
||
module.exports = function (app) { | ||
app.use( | ||
'/IPFS_API', | ||
createProxyMiddleware({ | ||
target: 'http://109.235.70.27:5001', | ||
pathRewrite: { '^/IPFS_API': '' }, | ||
changeOrigin: true, | ||
}) | ||
); | ||
app.use( | ||
'/TF_API', | ||
createProxyMiddleware({ | ||
target: 'http://109.235.70.27:8501', | ||
pathRewrite: { '^/TF_API': '' }, | ||
changeOrigin: true, | ||
}) | ||
); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ export {}; | |
declare global { | ||
interface Window { | ||
env: { | ||
IPFS_URL: string; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So you are putting these configurations in the global Window object? |
||
TENSORFLOW_URL: string; | ||
}; | ||
} | ||
|
@@ -12,10 +13,12 @@ const windowInstance: Window = window; | |
|
||
if (!window.env) { | ||
window.env = { | ||
IPFS_URL: process.env.REACT_APP_IPFS_URL!, | ||
TENSORFLOW_URL: process.env.REACT_APP_TENSORFLOW_URL!, | ||
}; | ||
} else { | ||
window.env = { | ||
IPFS_URL: window.env.IPFS_URL, | ||
TENSORFLOW_URL: window.env.TENSORFLOW_URL, | ||
}; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are currently connecting to the IPFS node on our own server.
I have created a follow-up to this issue that should connect to IPFS running locally first: #38