1
0
mirror of https://github.com/oceanprotocol/commons.git synced 2023-03-15 18:03:00 +01:00

Merge pull request #28 from oceanprotocol/feature/microservice-urlchecker

root app->/client, microservice in /server
This commit is contained in:
Jernej Pregelj 2019-03-20 11:24:08 +01:00 committed by GitHub
commit 7f4ea34c2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
119 changed files with 7164 additions and 73 deletions

12
.travis.sh Executable file
View File

@ -0,0 +1,12 @@
#/usr/bin/env/sh
set -e
components="server client"
for component in $components
do
echo "Testing: $component"
cd $component
npm install
npm test
cd ..
done

View File

@ -1,9 +1,8 @@
language: node_js
node_js: node
node_js:
- "11.10.1"
script:
- npm test
- npm run build
script: "./.travis.sh"
notifications:
email: false

View File

13
client/.travis.yml Normal file
View File

@ -0,0 +1,13 @@
language: node_js
node_js: node
script:
- npm test
- npm run build
notifications:
email: false
cache:
directories:
- node_modules

View File

@ -1427,6 +1427,12 @@
"integrity": "sha512-rzOhiQ55WzAiFgXRtitP/ZUT8iVNyllEpylJ5zHzR4vArUvMB39GTk+Zon/uAM0JxEFAWnwsxC2gH8s+tZ3Myg==",
"dev": true
},
"@types/filesize": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/@types/filesize/-/filesize-4.0.1.tgz",
"integrity": "sha512-GzPnNTUdyLSdLuKwPaI5dLJ783D/pEVTsikxX+3Q+8QNelZF2k5HQgEv0yFMo7N/vj5tvpRi9xAzXDQNUwuvfg==",
"dev": true
},
"@types/history": {
"version": "4.7.2",
"resolved": "https://registry.npmjs.org/@types/history/-/history-4.7.2.tgz",
@ -1439,6 +1445,12 @@
"integrity": "sha1-kU2r1QVG2bAUKAbkLHK8fCt+B4c=",
"dev": true
},
"@types/jasmine": {
"version": "3.3.9",
"resolved": "https://registry.npmjs.org/@types/jasmine/-/jasmine-3.3.9.tgz",
"integrity": "sha512-vw3VyFPa9mlba6NZPBZC3q2Zrnkgy5xuCVI43/tTLX6umdYrYvcFtQUKi2zH3PjFZQ9XCxNM/NMrM9uk8TPOzg==",
"dev": true
},
"@types/jest": {
"version": "24.0.9",
"resolved": "https://registry.npmjs.org/@types/jest/-/jest-24.0.9.tgz",
@ -3923,8 +3935,7 @@
"ansi-regex": {
"version": "2.1.1",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"aproba": {
"version": "1.2.0",
@ -3945,14 +3956,12 @@
"balanced-match": {
"version": "1.0.0",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"brace-expansion": {
"version": "1.1.11",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
@ -3967,20 +3976,17 @@
"code-point-at": {
"version": "1.1.0",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"concat-map": {
"version": "0.0.1",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"console-control-strings": {
"version": "1.1.0",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"core-util-is": {
"version": "1.0.2",
@ -4097,8 +4103,7 @@
"inherits": {
"version": "2.0.3",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"ini": {
"version": "1.3.5",
@ -4110,7 +4115,6 @@
"version": "1.0.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"number-is-nan": "^1.0.0"
}
@ -4125,7 +4129,6 @@
"version": "3.0.4",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"brace-expansion": "^1.1.7"
}
@ -4133,14 +4136,12 @@
"minimist": {
"version": "0.0.8",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"minipass": {
"version": "2.3.5",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"safe-buffer": "^5.1.2",
"yallist": "^3.0.0"
@ -4159,7 +4160,6 @@
"version": "0.5.1",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"minimist": "0.0.8"
}
@ -4240,8 +4240,7 @@
"number-is-nan": {
"version": "1.0.1",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"object-assign": {
"version": "4.1.1",
@ -4253,7 +4252,6 @@
"version": "1.4.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"wrappy": "1"
}
@ -4339,8 +4337,7 @@
"safe-buffer": {
"version": "5.1.2",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"safer-buffer": {
"version": "2.1.2",
@ -4376,7 +4373,6 @@
"version": "1.0.2",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0",
@ -4396,7 +4392,6 @@
"version": "3.0.1",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"ansi-regex": "^2.0.0"
}
@ -4440,14 +4435,12 @@
"wrappy": {
"version": "1.0.2",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"yallist": {
"version": "3.0.3",
"bundled": true,
"dev": true,
"optional": true
"dev": true
}
}
},
@ -7594,10 +7587,9 @@
}
},
"filesize": {
"version": "3.6.1",
"resolved": "https://registry.npmjs.org/filesize/-/filesize-3.6.1.tgz",
"integrity": "sha512-7KjR1vv6qnicaPMi1iiTcI85CyYwRO/PSFCu6SvqL8jN2Wjt/NIYQTFtFs7fSDCYOstUkEWIQGFUg5YZQfjlcg==",
"dev": true
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/filesize/-/filesize-4.1.2.tgz",
"integrity": "sha512-iSWteWtfNcrWQTkQw8ble2bnonSl7YJImsn9OZKpE2E4IHhXI78eASpDYUljXZZdYj36QsEKjOs/CsiDqmKMJw=="
},
"fill-range": {
"version": "2.2.4",
@ -8204,8 +8196,7 @@
"ansi-regex": {
"version": "2.1.1",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"aproba": {
"version": "1.2.0",
@ -8226,14 +8217,12 @@
"balanced-match": {
"version": "1.0.0",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"brace-expansion": {
"version": "1.1.11",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
@ -8248,20 +8237,17 @@
"code-point-at": {
"version": "1.1.0",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"concat-map": {
"version": "0.0.1",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"console-control-strings": {
"version": "1.1.0",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"core-util-is": {
"version": "1.0.2",
@ -8378,8 +8364,7 @@
"inherits": {
"version": "2.0.3",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"ini": {
"version": "1.3.5",
@ -8391,7 +8376,6 @@
"version": "1.0.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"number-is-nan": "^1.0.0"
}
@ -8406,7 +8390,6 @@
"version": "3.0.4",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"brace-expansion": "^1.1.7"
}
@ -8414,14 +8397,12 @@
"minimist": {
"version": "0.0.8",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"minipass": {
"version": "2.2.4",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"safe-buffer": "^5.1.1",
"yallist": "^3.0.0"
@ -8440,7 +8421,6 @@
"version": "0.5.1",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"minimist": "0.0.8"
}
@ -8521,8 +8501,7 @@
"number-is-nan": {
"version": "1.0.1",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"object-assign": {
"version": "4.1.1",
@ -8534,7 +8513,6 @@
"version": "1.4.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"wrappy": "1"
}
@ -8620,8 +8598,7 @@
"safe-buffer": {
"version": "5.1.1",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"safer-buffer": {
"version": "2.1.2",
@ -8657,7 +8634,6 @@
"version": "1.0.2",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0",
@ -8677,7 +8653,6 @@
"version": "3.0.1",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"ansi-regex": "^2.0.0"
}
@ -8721,14 +8696,12 @@
"wrappy": {
"version": "1.0.2",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"yallist": {
"version": "3.0.2",
"bundled": true,
"dev": true,
"optional": true
"dev": true
}
}
},
@ -17159,6 +17132,12 @@
"path-type": "^3.0.0"
}
},
"filesize": {
"version": "3.6.1",
"resolved": "https://registry.npmjs.org/filesize/-/filesize-3.6.1.tgz",
"integrity": "sha512-7KjR1vv6qnicaPMi1iiTcI85CyYwRO/PSFCu6SvqL8jN2Wjt/NIYQTFtFs7fSDCYOstUkEWIQGFUg5YZQfjlcg==",
"dev": true
},
"find-up": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz",
@ -22661,7 +22640,7 @@
"lodash": "^4.17.11",
"oboe": "2.1.4",
"url-parse": "1.4.4",
"websocket": "git://github.com/frozeman/WebSocket-Node.git#browserifyCompatible",
"websocket": "git://github.com/frozeman/WebSocket-Node.git#6c72925e3f8aaaea8dc8450f97627e85263999f2",
"xhr2-cookies": "1.1.0"
},
"dependencies": {
@ -22711,7 +22690,7 @@
"requires": {
"underscore": "1.8.3",
"web3-core-helpers": "1.0.0-beta.37",
"websocket": "git://github.com/frozeman/WebSocket-Node.git#browserifyCompatible"
"websocket": "git://github.com/frozeman/WebSocket-Node.git#6c72925e3f8aaaea8dc8450f97627e85263999f2"
}
},
"web3-shh": {

View File

@ -12,12 +12,14 @@
"format": "npm run format:js && npm run format:css",
"lint:css": "stylelint './src/**/*.{css,scss}'",
"lint:js": "eslint --ignore-path .gitignore --ignore-path .prettierignore --ext .ts,.tsx .",
"lint:fix": "eslint --fix --ignore-path .gitignore --ignore-path .prettierignore --ext .ts,.tsx .",
"lint": "npm run lint:js && npm run lint:css"
},
"dependencies": {
"@oceanprotocol/art": "^2.2.0",
"@oceanprotocol/squid": "^0.3.1",
"classnames": "^2.2.6",
"filesize": "^4.1.2",
"is-url": "^1.2.4",
"moment": "^2.24.0",
"query-string": "^6.2.0",
@ -33,7 +35,9 @@
},
"devDependencies": {
"@types/classnames": "^2.2.7",
"@types/filesize": "^4.0.1",
"@types/is-url": "^1.2.28",
"@types/jasmine": "^3.3.9",
"@types/jest": "^24.0.9",
"@types/node": "^11.9.5",
"@types/query-string": "^6.2.0",

View File

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 31 KiB

View File

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

View File

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

View File

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 25 KiB

View File

@ -1,3 +1,7 @@
export const serviceScheme = 'http'
export const serviceHost = 'localhost'
export const servicePort = 4000
export const nodeScheme = 'http'
export const nodeHost = 'localhost'
export const nodePort = 8545

View File

Before

Width:  |  Height:  |  Size: 932 B

After

Width:  |  Height:  |  Size: 932 B

View File

@ -32,3 +32,13 @@
opacity: .7;
}
}
.details {
font-size: $font-size-mini;
font-size: .85rem;
color: #6e7e93;
span {
padding-right: .5rem;
}
}

View File

@ -1,9 +1,18 @@
import React from 'react'
import styles from './Item.module.scss'
import filesize from 'filesize'
const Item = ({ item, removeItem }: { item: any; removeItem: any }) => (
<li>
<a href={item.url}>{item.url}</a>
<div className={styles.details}>
<span>url: {item.found ? 'confirmed' : 'unconfirmed'}</span>
<span>
size:
{item.found && item.size ? filesize(item.size) : 'unknown'}
</span>
<span>type: {item.found && item.type ? item.type : 'unknown'}</span>
</div>
<button
type="button"
className={styles.remove}

View File

@ -6,6 +6,8 @@ import ItemForm from './ItemForm'
import Item from './Item'
import styles from './index.module.scss'
import { serviceHost, servicePort, serviceScheme } from '../../../config'
interface FilesProps {
files: any[]
placeholder: string
@ -29,8 +31,28 @@ export default class Files extends PureComponent<FilesProps, FilesStates> {
this.setState({ isFormShown: !this.state.isFormShown })
}
public addItem = (value: string) => {
this.props.files.push({ url: value })
public addItem = async (value: string) => {
let res: any
let file: any = { url: value, found: false }
try {
const response = await fetch(
`${serviceScheme}://${serviceHost}:${servicePort}/api/v1/urlcheck`,
{
method: 'POST',
body: JSON.stringify({ url: value }),
headers: {
'Content-Type': 'application/json'
}
}
)
res = await response.json()
file.size = res.result.contentLength
file.type = res.result.contentType
file.found = res.result.found
} catch (error) {
// error
}
this.props.files.push(file)
const event = {
currentTarget: {
name: 'files',

Some files were not shown because too many files have changed in this diff Show More