mirror of
https://github.com/oceanprotocol/commons.git
synced 2023-03-15 18:03:00 +01:00
Merge branch 'master' into feature/consume-flow
This commit is contained in:
commit
8de81991df
9
client/.gitignore → .gitignore
vendored
9
client/.gitignore → .gitignore
vendored
@ -1,15 +1,14 @@
|
||||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||
|
||||
# dependencies
|
||||
/node_modules
|
||||
/.pnp
|
||||
.pnp.js
|
||||
node_modules
|
||||
|
||||
# testing
|
||||
/coverage
|
||||
coverage
|
||||
|
||||
# production
|
||||
/build
|
||||
build
|
||||
dist
|
||||
|
||||
# misc
|
||||
.DS_Store
|
@ -1,2 +1,3 @@
|
||||
node_modules
|
||||
build
|
||||
build
|
||||
dist
|
10
.travis.yml
10
.travis.yml
@ -1,12 +1,14 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- "11.10.1"
|
||||
node_js: node
|
||||
|
||||
script: "./.travis.sh"
|
||||
script:
|
||||
- ./scripts/install.sh
|
||||
- ./scripts/test.sh
|
||||
- ./scripts/build.sh
|
||||
|
||||
notifications:
|
||||
email: false
|
||||
|
||||
cache:
|
||||
directories:
|
||||
- node_modules
|
||||
- node_modules
|
||||
|
24
README.md
24
README.md
@ -2,40 +2,44 @@
|
||||
|
||||
<h1 align="center">commons-marketplace</h1>
|
||||
|
||||
> Marketplace front-end to explore, download, and publish open data sets.
|
||||
> Marketplace front-end and backend server to explore, download, and publish open data sets.
|
||||
|
||||
[![Build Status](https://travis-ci.com/oceanprotocol/commons-marketplace.svg?token=3psqw6c8KMDqfdGQ2x6d&branch=master)](https://travis-ci.com/oceanprotocol/commons-marketplace)
|
||||
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-7b1173.svg?style=flat-square)](https://github.com/prettier/prettier)
|
||||
[![js oceanprotocol](https://img.shields.io/badge/js-oceanprotocol-7b1173.svg)](https://github.com/oceanprotocol/eslint-config-oceanprotocol)
|
||||
[![css bigchaindb](https://img.shields.io/badge/css-bigchaindb-39BA91.svg)](https://github.com/bigchaindb/stylelint-config-bigchaindb)
|
||||
|
||||
- [Development](#development)
|
||||
- [Get Started](#get-started)
|
||||
- [Production](#production)
|
||||
- [Testing](#testing)
|
||||
- [Code Style](#code-style)
|
||||
- [License](#license)
|
||||
|
||||
<img alt="screen shot 2019-02-08 at 16 53 57" src="https://user-images.githubusercontent.com/90316/52489283-27080e80-2bc2-11e9-8ec0-508c21eb86f7.png">
|
||||
|
||||
## Development
|
||||
## Get Started
|
||||
|
||||
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
|
||||
To spin up both, the client and the server in a watch mode for local development, execute:
|
||||
|
||||
```bash
|
||||
npm install
|
||||
npm start
|
||||
```
|
||||
|
||||
Runs the app in the development mode.<br>
|
||||
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
|
||||
This will run client and server in development mode.<br>
|
||||
Open [http://localhost:3000](http://localhost:3000) to view the client in the browser.
|
||||
|
||||
The page will reload if you make edits.<br>
|
||||
You will also see any lint errors in the console.
|
||||
The page will reload if you make edits to files in either `./client` or `./server`.
|
||||
|
||||
## Production
|
||||
|
||||
To create a production build of both, the client and the server:
|
||||
|
||||
```bash
|
||||
npm run build
|
||||
```
|
||||
|
||||
Builds the app for production to the `build` folder.<br>
|
||||
It correctly bundles React in production mode and optimizes the build for the best performance.
|
||||
Builds the client for production to the `./client/build` folder, and the server into the `./server/dist` folder.
|
||||
|
||||
## Testing
|
||||
|
||||
|
@ -1,13 +0,0 @@
|
||||
language: node_js
|
||||
node_js: node
|
||||
|
||||
script:
|
||||
- npm test
|
||||
- npm run build
|
||||
|
||||
notifications:
|
||||
email: false
|
||||
|
||||
cache:
|
||||
directories:
|
||||
- node_modules
|
1625
client/package-lock.json
generated
1625
client/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -1,19 +1,13 @@
|
||||
{
|
||||
"name": "commons-marketplace",
|
||||
"name": "commons-marketplace-client",
|
||||
"description": "Ocean Protocol marketplace frontend to explore, download, and publish open data sets.",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"license": "Apache-2.0",
|
||||
"scripts": {
|
||||
"start": "react-scripts start",
|
||||
"build": "react-scripts build",
|
||||
"test": "npm run lint && react-scripts test",
|
||||
"eject": "react-scripts eject",
|
||||
"format:js": "prettier --parser typescript --write '**/*.{js,jsx,ts,tsx}'",
|
||||
"format:css": "prettier-stylelint --write --quiet 'src/**/*.{css,scss}'",
|
||||
"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"
|
||||
"build": "react-scripts --max_old_space_size=4096 build",
|
||||
"test": "react-scripts test",
|
||||
"eject": "react-scripts eject"
|
||||
},
|
||||
"dependencies": {
|
||||
"@oceanprotocol/art": "^2.2.0",
|
||||
@ -22,46 +16,36 @@
|
||||
"filesize": "^4.1.2",
|
||||
"is-url": "^1.2.4",
|
||||
"moment": "^2.24.0",
|
||||
"query-string": "^6.2.0",
|
||||
"react": "^16.8.3",
|
||||
"react-dom": "^16.8.3",
|
||||
"query-string": "^6.4.0",
|
||||
"react": "^16.8.5",
|
||||
"react-dom": "^16.8.5",
|
||||
"react-helmet": "^5.2.0",
|
||||
"react-moment": "^0.8.4",
|
||||
"react-popper": "^1.3.3",
|
||||
"react-router-dom": "^4.3.1",
|
||||
"react-transition-group": "^2.6.0",
|
||||
"react-router-dom": "^5.0.0",
|
||||
"react-transition-group": "^2.7.0",
|
||||
"slugify": "^1.3.4",
|
||||
"web3": "^1.0.0-beta.48"
|
||||
"web3": "^1.0.0-beta.50"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/classnames": "^2.2.7",
|
||||
"@types/filesize": "^4.0.1",
|
||||
"@types/filesize": "^4.1.0",
|
||||
"@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",
|
||||
"@types/react": "^16.8.5",
|
||||
"@types/react-dom": "^16.8.2",
|
||||
"@types/jest": "^24.0.11",
|
||||
"@types/query-string": "^6.3.0",
|
||||
"@types/react": "^16.8.8",
|
||||
"@types/react-dom": "^16.8.3",
|
||||
"@types/react-helmet": "^5.0.8",
|
||||
"@types/react-router-dom": "^4.3.1",
|
||||
"@types/react-transition-group": "^2.0.16",
|
||||
"@types/web3": "^1.0.18",
|
||||
"@typescript-eslint/eslint-plugin": "^1.4.2",
|
||||
"@typescript-eslint/parser": "^1.4.2",
|
||||
"eslint": "5.12.0",
|
||||
"eslint-config-oceanprotocol": "^1.3.0",
|
||||
"eslint-config-prettier": "^4.1.0",
|
||||
"eslint-plugin-prettier": "^3.0.1",
|
||||
"node-sass": "^4.11.0",
|
||||
"prettier": "^1.16.4",
|
||||
"prettier-stylelint": "^0.4.2",
|
||||
"react-scripts": "^2.1.5",
|
||||
"stylelint": "^9.10.1",
|
||||
"stylelint-config-bigchaindb": "^1.2.1",
|
||||
"stylelint-config-css-modules": "^1.3.0",
|
||||
"stylelint-config-standard": "^18.2.0",
|
||||
"typescript": "^3.3.3333"
|
||||
"react-scripts": "^2.1.8",
|
||||
"typescript": "^3.3.4000"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/oceanprotocol/commons-marketplace"
|
||||
},
|
||||
"browserslist": [
|
||||
">0.2%",
|
||||
|
@ -4,7 +4,6 @@ import Route from '../components/templates/Route'
|
||||
import { User } from '../context/User'
|
||||
import Asset from '../components/molecules/Asset'
|
||||
import styles from './Search.module.scss'
|
||||
import { Logger } from '@oceanprotocol/squid'
|
||||
|
||||
interface SearchState {
|
||||
results: any[]
|
||||
|
6848
package-lock.json
generated
Normal file
6848
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
41
package.json
Normal file
41
package.json
Normal file
@ -0,0 +1,41 @@
|
||||
{
|
||||
"name": "commons-marketplace",
|
||||
"description": "Ocean Protocol marketplace to explore, download, and publish open data sets.",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"license": "Apache-2.0",
|
||||
"scripts": {
|
||||
"install": "./scripts/install.sh",
|
||||
"start": "concurrently \"cd client && npm run start\" \"cd server && npm run start-watch\"",
|
||||
"build": "./scripts/build.sh",
|
||||
"test": "npm run lint && scripts/test.sh",
|
||||
"format:js": "prettier --parser typescript --write '**/*.{js,jsx,ts,tsx}'",
|
||||
"format:css": "prettier-stylelint --ignore-path .gitignore --write --quiet '**/*.{css,scss}'",
|
||||
"format": "npm run format:js && npm run format:css",
|
||||
"lint:css": "stylelint --ignore-path .gitignore './**/*.{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": {},
|
||||
"devDependencies": {
|
||||
"@typescript-eslint/eslint-plugin": "^1.4.2",
|
||||
"@typescript-eslint/parser": "^1.4.2",
|
||||
"concurrently": "^4.1.0",
|
||||
"eslint": "5.12.0",
|
||||
"eslint-config-oceanprotocol": "^1.3.0",
|
||||
"eslint-config-prettier": "^4.1.0",
|
||||
"eslint-plugin-prettier": "^3.0.1",
|
||||
"prettier": "^1.16.4",
|
||||
"prettier-stylelint": "^0.4.2",
|
||||
"stylelint": "^9.10.1",
|
||||
"stylelint-config-bigchaindb": "^1.2.1",
|
||||
"stylelint-config-css-modules": "^1.3.0",
|
||||
"stylelint-config-standard": "^18.2.0",
|
||||
"typescript": "^3.3.4000"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/oceanprotocol/commons-marketplace"
|
||||
}
|
||||
}
|
12
scripts/build.sh
Executable file
12
scripts/build.sh
Executable file
@ -0,0 +1,12 @@
|
||||
#/usr/bin/env/sh
|
||||
set -e
|
||||
|
||||
components="server client"
|
||||
|
||||
for component in $components
|
||||
do
|
||||
echo "Building: $component"
|
||||
cd $component
|
||||
npm run build
|
||||
cd ..
|
||||
done
|
12
scripts/install.sh
Executable file
12
scripts/install.sh
Executable file
@ -0,0 +1,12 @@
|
||||
#/usr/bin/env/sh
|
||||
set -e
|
||||
|
||||
components="server client"
|
||||
|
||||
for component in $components
|
||||
do
|
||||
echo "\n\nInstalling dependencies: $component\n"
|
||||
cd $component
|
||||
npm install
|
||||
cd ..
|
||||
done
|
@ -1,12 +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
|
||||
done
|
38
server/.gitignore
vendored
38
server/.gitignore
vendored
@ -1,38 +0,0 @@
|
||||
lib-cov
|
||||
*.seed
|
||||
*.log
|
||||
*.csv
|
||||
*.dat
|
||||
*.out
|
||||
*.pid
|
||||
*.gz
|
||||
*.swp
|
||||
|
||||
pids
|
||||
logs
|
||||
results
|
||||
tmp
|
||||
|
||||
# Build
|
||||
dist
|
||||
|
||||
# Coverage reports
|
||||
coverage
|
||||
|
||||
# API keys and secrets
|
||||
.env
|
||||
|
||||
# Dependency directory
|
||||
node_modules
|
||||
bower_components
|
||||
|
||||
# Editors
|
||||
.idea
|
||||
*.iml
|
||||
|
||||
# OS metadata
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
|
||||
# Ignore built ts files
|
||||
dist/**/*
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"watch": ["src"],
|
||||
"ext": "ts",
|
||||
"ignore": ["src/**/*.spec.ts"],
|
||||
"exec": "ts-node src/index.ts"
|
||||
}
|
||||
"watch": ["src"],
|
||||
"ext": "ts",
|
||||
"ignore": ["src/**/*.spec.ts"],
|
||||
"exec": "ts-node src/index.ts"
|
||||
}
|
||||
|
135
server/package-lock.json
generated
135
server/package-lock.json
generated
@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "backend",
|
||||
"name": "commons-marketplace-server",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
@ -574,65 +574,6 @@
|
||||
"resolved": "https://registry.npmjs.org/aws4/-/aws4-1.8.0.tgz",
|
||||
"integrity": "sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ=="
|
||||
},
|
||||
"babel-code-frame": {
|
||||
"version": "6.26.0",
|
||||
"resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.26.0.tgz",
|
||||
"integrity": "sha1-Y/1D99weO7fONZR9uP42mj9Yx0s=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"chalk": "^1.1.3",
|
||||
"esutils": "^2.0.2",
|
||||
"js-tokens": "^3.0.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"ansi-regex": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz",
|
||||
"integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=",
|
||||
"dev": true
|
||||
},
|
||||
"ansi-styles": {
|
||||
"version": "2.2.1",
|
||||
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz",
|
||||
"integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=",
|
||||
"dev": true
|
||||
},
|
||||
"chalk": {
|
||||
"version": "1.1.3",
|
||||
"resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz",
|
||||
"integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"ansi-styles": "^2.2.1",
|
||||
"escape-string-regexp": "^1.0.2",
|
||||
"has-ansi": "^2.0.0",
|
||||
"strip-ansi": "^3.0.0",
|
||||
"supports-color": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"js-tokens": {
|
||||
"version": "3.0.2",
|
||||
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz",
|
||||
"integrity": "sha1-mGbfOVECEw449/mWvOtlRDIJwls=",
|
||||
"dev": true
|
||||
},
|
||||
"strip-ansi": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz",
|
||||
"integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"ansi-regex": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"supports-color": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz",
|
||||
"integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"babel-jest": {
|
||||
"version": "24.1.0",
|
||||
"resolved": "https://registry.npmjs.org/babel-jest/-/babel-jest-24.1.0.tgz",
|
||||
@ -899,12 +840,6 @@
|
||||
"resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz",
|
||||
"integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A=="
|
||||
},
|
||||
"builtin-modules": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz",
|
||||
"integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=",
|
||||
"dev": true
|
||||
},
|
||||
"busboy": {
|
||||
"version": "0.2.14",
|
||||
"resolved": "https://registry.npmjs.org/busboy/-/busboy-0.2.14.tgz",
|
||||
@ -1144,7 +1079,8 @@
|
||||
"version": "2.17.1",
|
||||
"resolved": "https://registry.npmjs.org/commander/-/commander-2.17.1.tgz",
|
||||
"integrity": "sha512-wPMUt6FnH2yzG95SA6mzjQOEKUU3aLaDEmzs1ti+1E9h+CsrZghRlqEM/EJ4KscsQVG8uNN4uVreUeT8+drlgg==",
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"compare-versions": {
|
||||
"version": "3.4.0",
|
||||
@ -2866,23 +2802,6 @@
|
||||
"function-bind": "^1.1.1"
|
||||
}
|
||||
},
|
||||
"has-ansi": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz",
|
||||
"integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"ansi-regex": "^2.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"ansi-regex": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz",
|
||||
"integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"has-flag": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz",
|
||||
@ -3834,9 +3753,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"js-yaml": {
|
||||
"version": "3.12.2",
|
||||
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.12.2.tgz",
|
||||
"integrity": "sha512-QHn/Lh/7HhZ/Twc7vJYQTkjuCa0kaCcDcjK5Zlk2rvnUpy7DxMJ23+Jc2dcyvltwQVg1nygAVlB2oRDFHoRS5Q==",
|
||||
"version": "3.13.0",
|
||||
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.0.tgz",
|
||||
"integrity": "sha512-pZZoSxcCYco+DIKBTimr67J6Hy+EYGZDY/HCWC+iAEA9h1ByhMXAIVUXMcMFpOCxQ/xjXmPI2MkDL5HRm5eFrQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"argparse": "^1.0.7",
|
||||
@ -6110,47 +6029,11 @@
|
||||
"yn": "^3.0.0"
|
||||
}
|
||||
},
|
||||
"tslib": {
|
||||
"version": "1.9.3",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.3.tgz",
|
||||
"integrity": "sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ==",
|
||||
"dev": true
|
||||
},
|
||||
"tslint": {
|
||||
"version": "5.13.1",
|
||||
"resolved": "https://registry.npmjs.org/tslint/-/tslint-5.13.1.tgz",
|
||||
"integrity": "sha512-fplQqb2miLbcPhyHoMV4FU9PtNRbgmm/zI5d3SZwwmJQM6V0eodju+hplpyfhLWpmwrDNfNYU57uYRb8s0zZoQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"babel-code-frame": "^6.22.0",
|
||||
"builtin-modules": "^1.1.1",
|
||||
"chalk": "^2.3.0",
|
||||
"commander": "^2.12.1",
|
||||
"diff": "^3.2.0",
|
||||
"glob": "^7.1.1",
|
||||
"js-yaml": "^3.7.0",
|
||||
"minimatch": "^3.0.4",
|
||||
"mkdirp": "^0.5.1",
|
||||
"resolve": "^1.3.2",
|
||||
"semver": "^5.3.0",
|
||||
"tslib": "^1.8.0",
|
||||
"tsutils": "^2.27.2"
|
||||
}
|
||||
},
|
||||
"tsscmp": {
|
||||
"version": "1.0.6",
|
||||
"resolved": "https://registry.npmjs.org/tsscmp/-/tsscmp-1.0.6.tgz",
|
||||
"integrity": "sha512-LxhtAkPDTkVCMQjt2h6eBVY28KCjikZqZfMcC15YBeNjkgUpdCfBu5HoiOTDu86v6smE8yOjyEktJ8hlbANHQA=="
|
||||
},
|
||||
"tsutils": {
|
||||
"version": "2.29.0",
|
||||
"resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.29.0.tgz",
|
||||
"integrity": "sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"tslib": "^1.8.1"
|
||||
}
|
||||
},
|
||||
"tunnel-agent": {
|
||||
"version": "0.6.0",
|
||||
"resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz",
|
||||
@ -6194,9 +6077,9 @@
|
||||
"integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c="
|
||||
},
|
||||
"typescript": {
|
||||
"version": "3.3.3333",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.3.3333.tgz",
|
||||
"integrity": "sha512-JjSKsAfuHBE/fB2oZ8NxtRTk5iGcg6hkYXMnZ3Wc+b2RSqejEqTaem11mHASMnFilHrax3sLK0GDzcJrekZYLw==",
|
||||
"version": "3.3.4000",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.3.4000.tgz",
|
||||
"integrity": "sha512-jjOcCZvpkl2+z7JFn0yBOoLQyLoIkNZAs/fYJkUG6VKy6zLPHJGfQJYFHzibB6GJaF/8QrcECtlQ5cpvRHSMEA==",
|
||||
"dev": true
|
||||
},
|
||||
"uglify-js": {
|
||||
|
@ -1,22 +1,17 @@
|
||||
{
|
||||
"name": "backend",
|
||||
"name": "commons-marketplace-server",
|
||||
"description": "Ocean Protocol marketplace backend.",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"license": "Apache-2.0",
|
||||
"main": "dist/index.js",
|
||||
"scripts": {
|
||||
"start": "npm run serve",
|
||||
"start": "node dist/index.js",
|
||||
"start-watch": "nodemon",
|
||||
"build": "npm run build-ts && npm run tslint",
|
||||
"watch": "npm run watch-ts",
|
||||
"serve": "node dist/index.js",
|
||||
"build": "tsc",
|
||||
"watch": "tsc -w",
|
||||
"test": "jest --coverage",
|
||||
"watch-test": "npm run test --watchAll",
|
||||
"build-ts": "tsc",
|
||||
"watch-ts": "tsc -w",
|
||||
"tslint": "tslint -c tslint.json -p tsconfig.json"
|
||||
"watch-test": "npm run test --watchAll"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"body-parser": "^1.18.3",
|
||||
"color-js": "^1.0.5",
|
||||
@ -48,8 +43,11 @@
|
||||
"supertest": "^3.4.2",
|
||||
"ts-jest": "^24.0.0",
|
||||
"ts-node": "^8.0.2",
|
||||
"tslint": "^5.12.1",
|
||||
"typescript": "^3.3.3"
|
||||
"typescript": "^3.3.4000"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/oceanprotocol/commons-marketplace"
|
||||
},
|
||||
"jest": {
|
||||
"preset": "ts-jest"
|
||||
|
@ -1,5 +1,7 @@
|
||||
module.exports = {
|
||||
const config = {
|
||||
app: {
|
||||
port: 4000
|
||||
port: 4000
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export default config
|
||||
|
@ -1,58 +1,65 @@
|
||||
import debug from "debug";
|
||||
import express from "express";
|
||||
import compression from "compression";
|
||||
import morgan from "morgan";
|
||||
import bodyParser from "body-parser";
|
||||
import debug from 'debug'
|
||||
import express from 'express'
|
||||
import compression from 'compression'
|
||||
import morgan from 'morgan'
|
||||
import bodyParser from 'body-parser'
|
||||
|
||||
// routes
|
||||
import UrlCheckRouter from "./routes/UrlCheckRouter";
|
||||
import UrlCheckRouter from './routes/UrlCheckRouter'
|
||||
|
||||
// config
|
||||
const config = require("./config/config");
|
||||
import config from './config/config'
|
||||
|
||||
// debug
|
||||
const log = debug("server:index");
|
||||
const log = debug('server:index')
|
||||
|
||||
const app = express();
|
||||
app.use((req, res, next) => {
|
||||
res.header("Access-Control-Allow-Origin", "*");
|
||||
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, Authorization");
|
||||
res.header("Access-Control-Allow-Methods", "GET, POST, OPTIONS, PUT, DELETE");
|
||||
next();
|
||||
});
|
||||
app.use(morgan("dev"));
|
||||
app.use(bodyParser.json());
|
||||
app.use(bodyParser.urlencoded({ extended: false }));
|
||||
app.use(compression());
|
||||
// routes
|
||||
app.use("/api/v1/urlcheck", UrlCheckRouter);
|
||||
/// catch 404
|
||||
app.use((req, res, next) => {
|
||||
res.status(404).send();
|
||||
});
|
||||
// listen
|
||||
const server = app.listen(config.app.port);
|
||||
server.on("listening", onListening);
|
||||
server.on("error", onError);
|
||||
const app = express()
|
||||
|
||||
function onListening(): void {
|
||||
log("Server thread started");
|
||||
log('Server thread started')
|
||||
}
|
||||
|
||||
function onError(error: NodeJS.ErrnoException): void {
|
||||
if (error.syscall !== "listen") throw error;
|
||||
switch (error.code) {
|
||||
case "EACCES":
|
||||
log("Required elevated privileges");
|
||||
process.exit(1);
|
||||
break;
|
||||
case "EADDRINUSE":
|
||||
log("Port is already in use");
|
||||
process.exit(1);
|
||||
break;
|
||||
default:
|
||||
throw error;
|
||||
}
|
||||
if (error.syscall !== 'listen') throw error
|
||||
switch (error.code) {
|
||||
case 'EACCES':
|
||||
log('Required elevated privileges')
|
||||
process.exit(1)
|
||||
case 'EADDRINUSE':
|
||||
log('Port is already in use')
|
||||
process.exit(1)
|
||||
default:
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
export default server;
|
||||
app.use((req, res, next) => {
|
||||
res.header('Access-Control-Allow-Origin', '*')
|
||||
res.header(
|
||||
'Access-Control-Allow-Headers',
|
||||
'Origin, X-Requested-With, Content-Type, Accept, Authorization'
|
||||
)
|
||||
res.header(
|
||||
'Access-Control-Allow-Methods',
|
||||
'GET, POST, OPTIONS, PUT, DELETE'
|
||||
)
|
||||
next()
|
||||
})
|
||||
app.use(morgan('dev'))
|
||||
app.use(bodyParser.json())
|
||||
app.use(bodyParser.urlencoded({ extended: false }))
|
||||
app.use(compression())
|
||||
// routes
|
||||
app.use('/api/v1/urlcheck', UrlCheckRouter)
|
||||
|
||||
/// catch 404
|
||||
app.use((req, res, next) => {
|
||||
res.status(404).send()
|
||||
})
|
||||
|
||||
// listen
|
||||
const server = app.listen(config.app.port)
|
||||
server.on('listening', onListening)
|
||||
server.on('error', onError)
|
||||
|
||||
export default server
|
||||
|
@ -1,58 +1,69 @@
|
||||
import { Router, Request, Response, NextFunction } from "express";
|
||||
import request from "request";
|
||||
import { Router, Request, Response, NextFunction } from 'express'
|
||||
import request from 'request'
|
||||
|
||||
export class UrlCheckRouter {
|
||||
router: Router;
|
||||
public router: Router
|
||||
|
||||
/**
|
||||
* Initialize the UrlCheckRouter
|
||||
*/
|
||||
constructor() {
|
||||
this.router = Router();
|
||||
}
|
||||
|
||||
public checkUrl(req: Request, res: Response, next: NextFunction) {
|
||||
if (!req.body.url) {
|
||||
return res.send({ status: "error", message: "missing url" });
|
||||
/**
|
||||
* Initialize the UrlCheckRouter
|
||||
*/
|
||||
public constructor() {
|
||||
this.router = Router()
|
||||
}
|
||||
request(
|
||||
{
|
||||
method: "HEAD",
|
||||
url: req.body.url,
|
||||
headers: { Range: "bytes=0-" }
|
||||
},
|
||||
(error, response) => {
|
||||
if (response.statusCode.toString().startsWith("2")) {
|
||||
const result: any = {};
|
||||
result.found = true;
|
||||
if (response.headers["content-length"]) {
|
||||
result.contentLength = response.headers["content-length"];
|
||||
}
|
||||
if (response.headers["content-type"]) {
|
||||
const typeAndCharset = response.headers["content-type"].split(";");
|
||||
result.contentType = typeAndCharset[0];
|
||||
if (typeAndCharset[1]) {
|
||||
result.contentCharset = typeAndCharset[1].split("=")[1];
|
||||
}
|
||||
}
|
||||
return res.send({ status: "success", result: result });
|
||||
}
|
||||
return res.send({ status: "error", message: error });
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Take each handler, and attach to one of the Express.Router's
|
||||
* endpoints.
|
||||
*/
|
||||
init() {
|
||||
this.router.post("/", this.checkUrl);
|
||||
}
|
||||
public checkUrl(req: Request, res: Response, next: NextFunction) {
|
||||
if (!req.body.url) {
|
||||
return res.send({ status: 'error', message: 'missing url' })
|
||||
}
|
||||
request(
|
||||
{
|
||||
method: 'HEAD',
|
||||
url: req.body.url,
|
||||
headers: { Range: 'bytes=0-' }
|
||||
},
|
||||
(error, response) => {
|
||||
if (response.statusCode.toString().startsWith('2')) {
|
||||
const result: any = {}
|
||||
result.found = true
|
||||
|
||||
if (response.headers['content-length']) {
|
||||
result.contentLength =
|
||||
response.headers['content-length']
|
||||
}
|
||||
|
||||
if (response.headers['content-type']) {
|
||||
const typeAndCharset = response.headers[
|
||||
'content-type'
|
||||
].split(';')
|
||||
|
||||
result.contentType = typeAndCharset[0] // eslint-disable-line prefer-destructuring
|
||||
|
||||
if (typeAndCharset[1]) {
|
||||
/* eslint-disable prefer-destructuring */
|
||||
result.contentCharset = typeAndCharset[1].split(
|
||||
'='
|
||||
)[1]
|
||||
/* eslint-enable prefer-destructuring */
|
||||
}
|
||||
}
|
||||
return res.send({ status: 'success', result })
|
||||
}
|
||||
return res.send({ status: 'error', message: error })
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Take each handler, and attach to one of the Express.Router's
|
||||
* endpoints.
|
||||
*/
|
||||
public init() {
|
||||
this.router.post('/', this.checkUrl)
|
||||
}
|
||||
}
|
||||
|
||||
// Create the MeRouter, and export its configured Express.Router
|
||||
const urlCheckRoutes = new UrlCheckRouter();
|
||||
urlCheckRoutes.init();
|
||||
const urlCheckRoutes = new UrlCheckRouter()
|
||||
urlCheckRoutes.init()
|
||||
|
||||
export default urlCheckRoutes.router;
|
||||
export default urlCheckRoutes.router
|
||||
|
@ -1,15 +1,15 @@
|
||||
import request from "supertest";
|
||||
import server from "../src";
|
||||
import {} from "jasmine";
|
||||
import request from 'supertest'
|
||||
import server from '../src'
|
||||
import {} from 'jasmine'
|
||||
|
||||
afterAll((done) => {
|
||||
server.close(done);
|
||||
});
|
||||
afterAll(done => {
|
||||
server.close(done)
|
||||
})
|
||||
|
||||
describe("POST /api/v1/urlcheck", () => {
|
||||
it('responds with json', function(done) {
|
||||
request(server)
|
||||
.post('/api/v1/urlcheck')
|
||||
.expect(200, done);
|
||||
});
|
||||
});
|
||||
describe('POST /api/v1/urlcheck', () => {
|
||||
it('responds with json', function(done) {
|
||||
request(server)
|
||||
.post('/api/v1/urlcheck')
|
||||
.expect(200, done)
|
||||
})
|
||||
})
|
||||
|
@ -1,25 +1,18 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"esModuleInterop": true,
|
||||
"target": "es6",
|
||||
"noImplicitAny": false,
|
||||
"moduleResolution": "node",
|
||||
"sourceMap": true,
|
||||
"outDir": "dist",
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"*": [
|
||||
"node_modules/*",
|
||||
"src/types/*"
|
||||
]
|
||||
},
|
||||
"types": [ "node" ],
|
||||
"typeRoots": [
|
||||
"node_modules/@types"
|
||||
],
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"esModuleInterop": true,
|
||||
"target": "es6",
|
||||
"noImplicitAny": false,
|
||||
"moduleResolution": "node",
|
||||
"sourceMap": true,
|
||||
"outDir": "dist",
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"*": ["node_modules/*", "src/types/*"]
|
||||
},
|
||||
"include": [
|
||||
"src/**/*"
|
||||
]
|
||||
}
|
||||
"types": ["node"],
|
||||
"typeRoots": ["node_modules/@types"]
|
||||
},
|
||||
"include": ["src/**/*"]
|
||||
}
|
||||
|
@ -1,60 +0,0 @@
|
||||
{
|
||||
"rules": {
|
||||
"class-name": true,
|
||||
"comment-format": [
|
||||
true,
|
||||
"check-space"
|
||||
],
|
||||
"indent": [
|
||||
true,
|
||||
"spaces"
|
||||
],
|
||||
"one-line": [
|
||||
true,
|
||||
"check-open-brace",
|
||||
"check-whitespace"
|
||||
],
|
||||
"no-var-keyword": true,
|
||||
"quotemark": [
|
||||
true,
|
||||
"double",
|
||||
"avoid-escape"
|
||||
],
|
||||
"semicolon": [
|
||||
true,
|
||||
"always",
|
||||
"ignore-bound-class-methods"
|
||||
],
|
||||
"whitespace": [
|
||||
true,
|
||||
"check-branch",
|
||||
"check-decl",
|
||||
"check-operator",
|
||||
"check-module",
|
||||
"check-separator",
|
||||
"check-type"
|
||||
],
|
||||
"typedef-whitespace": [
|
||||
true,
|
||||
{
|
||||
"call-signature": "nospace",
|
||||
"index-signature": "nospace",
|
||||
"parameter": "nospace",
|
||||
"property-declaration": "nospace",
|
||||
"variable-declaration": "nospace"
|
||||
},
|
||||
{
|
||||
"call-signature": "onespace",
|
||||
"index-signature": "onespace",
|
||||
"parameter": "onespace",
|
||||
"property-declaration": "onespace",
|
||||
"variable-declaration": "onespace"
|
||||
}
|
||||
],
|
||||
"no-internal-module": true,
|
||||
"no-trailing-whitespace": true,
|
||||
"no-null-keyword": true,
|
||||
"prefer-const": true,
|
||||
"jsdoc-format": true
|
||||
}
|
||||
}
|
3
tsconfig.json
Normal file
3
tsconfig.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"include": ["client/src", "server/src"]
|
||||
}
|
Loading…
Reference in New Issue
Block a user