mirror of
https://github.com/oceanprotocol/commons.git
synced 2023-03-15 18:03:00 +01:00
one dev interface for client & server
This commit is contained in:
parent
366f48b9ad
commit
7e42991706
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.
|
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||||
|
|
||||||
# dependencies
|
# dependencies
|
||||||
/node_modules
|
node_modules
|
||||||
/.pnp
|
|
||||||
.pnp.js
|
|
||||||
|
|
||||||
# testing
|
# testing
|
||||||
/coverage
|
coverage
|
||||||
|
|
||||||
# production
|
# production
|
||||||
/build
|
build
|
||||||
|
dist
|
||||||
|
|
||||||
# misc
|
# misc
|
||||||
.DS_Store
|
.DS_Store
|
@ -1,2 +1,3 @@
|
|||||||
node_modules
|
node_modules
|
||||||
build
|
build
|
||||||
|
dist
|
@ -1,8 +1,10 @@
|
|||||||
language: node_js
|
language: node_js
|
||||||
node_js:
|
node_js:
|
||||||
- "11.10.1"
|
- '11.10.1'
|
||||||
|
|
||||||
script: "./.travis.sh"
|
script:
|
||||||
|
- ./scripts/install.sh
|
||||||
|
- ./scripts/test.sh
|
||||||
|
|
||||||
notifications:
|
notifications:
|
||||||
email: false
|
email: false
|
||||||
|
24
README.md
24
README.md
@ -2,40 +2,44 @@
|
|||||||
|
|
||||||
<h1 align="center">commons-marketplace</h1>
|
<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)
|
[![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)
|
[![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)
|
[![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)
|
[![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)
|
- [Testing](#testing)
|
||||||
- [Code Style](#code-style)
|
- [Code Style](#code-style)
|
||||||
- [License](#license)
|
- [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">
|
<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
|
```bash
|
||||||
|
npm install
|
||||||
npm start
|
npm start
|
||||||
```
|
```
|
||||||
|
|
||||||
Runs the app in the development mode.<br>
|
This will run client and server in development mode.<br>
|
||||||
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
|
Open [http://localhost:3000](http://localhost:3000) to view the client in the browser. The server is
|
||||||
|
|
||||||
The page will reload if you make edits.<br>
|
The page will reload if you make edits to files in either `./client` or `./server`.
|
||||||
You will also see any lint errors in the console.
|
|
||||||
|
## Production
|
||||||
|
|
||||||
|
To create a production build of both, the client and the server:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm run build
|
npm run build
|
||||||
```
|
```
|
||||||
|
|
||||||
Builds the app for production to the `build` folder.<br>
|
Builds the client for production to the `./client/build` folder, and the server into the `./server/dist` folder.
|
||||||
It correctly bundles React in production mode and optimizes the build for the best performance.
|
|
||||||
|
|
||||||
## Testing
|
## Testing
|
||||||
|
|
||||||
|
@ -1,13 +0,0 @@
|
|||||||
language: node_js
|
|
||||||
node_js: node
|
|
||||||
|
|
||||||
script:
|
|
||||||
- npm test
|
|
||||||
- npm run build
|
|
||||||
|
|
||||||
notifications:
|
|
||||||
email: false
|
|
||||||
|
|
||||||
cache:
|
|
||||||
directories:
|
|
||||||
- node_modules
|
|
2387
client/package-lock.json
generated
2387
client/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -1,19 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "commons-marketplace",
|
"name": "commons-marketplace-client",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "react-scripts start",
|
"start": "react-scripts start",
|
||||||
"build": "react-scripts build",
|
"build": "react-scripts build",
|
||||||
"test": "npm run lint && react-scripts test",
|
"test": "react-scripts test",
|
||||||
"eject": "react-scripts eject",
|
"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"
|
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@oceanprotocol/art": "^2.2.0",
|
"@oceanprotocol/art": "^2.2.0",
|
||||||
@ -47,21 +40,8 @@
|
|||||||
"@types/react-router-dom": "^4.3.1",
|
"@types/react-router-dom": "^4.3.1",
|
||||||
"@types/react-transition-group": "^2.0.16",
|
"@types/react-transition-group": "^2.0.16",
|
||||||
"@types/web3": "^1.0.18",
|
"@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",
|
"node-sass": "^4.11.0",
|
||||||
"prettier": "^1.16.4",
|
"react-scripts": "^2.1.5"
|
||||||
"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"
|
|
||||||
},
|
},
|
||||||
"browserslist": [
|
"browserslist": [
|
||||||
">0.2%",
|
">0.2%",
|
||||||
|
6475
package-lock.json
generated
Normal file
6475
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
40
package.json
Normal file
40
package.json
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
{
|
||||||
|
"name": "commons-marketplace",
|
||||||
|
"version": "0.1.0",
|
||||||
|
"private": true,
|
||||||
|
"scripts": {
|
||||||
|
"install": "./scripts/install.sh",
|
||||||
|
"start": "cd client && npm run start",
|
||||||
|
"build": "cd client && npm run build",
|
||||||
|
"test": "npm run lint && scripts/test.sh",
|
||||||
|
"format:js": "prettier --parser typescript --write '**/*.{js,jsx,ts,tsx}'",
|
||||||
|
"format:css": "prettier-stylelint --write --quiet '**/*.{css,scss}'",
|
||||||
|
"format": "npm run format:js && npm run format:css",
|
||||||
|
"lint:css": "stylelint './**/*.{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",
|
||||||
|
"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.3333"
|
||||||
|
},
|
||||||
|
"browserslist": [
|
||||||
|
">0.2%",
|
||||||
|
"not dead",
|
||||||
|
"not ie <= 11",
|
||||||
|
"not op_mini all"
|
||||||
|
]
|
||||||
|
}
|
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 "Installing dependencies: $component"
|
||||||
|
cd $component
|
||||||
|
npm install
|
||||||
|
cd ..
|
||||||
|
done
|
2
.travis.sh → scripts/test.sh
Executable file → Normal file
2
.travis.sh → scripts/test.sh
Executable file → Normal file
@ -1,12 +1,12 @@
|
|||||||
#/usr/bin/env/sh
|
#/usr/bin/env/sh
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
components="server client"
|
components="server client"
|
||||||
|
|
||||||
for component in $components
|
for component in $components
|
||||||
do
|
do
|
||||||
echo "Testing: $component"
|
echo "Testing: $component"
|
||||||
cd $component
|
cd $component
|
||||||
npm install
|
|
||||||
npm test
|
npm test
|
||||||
cd ..
|
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/**/*
|
|
129
server/package-lock.json
generated
129
server/package-lock.json
generated
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "backend",
|
"name": "commons-marketplace-server",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
@ -574,65 +574,6 @@
|
|||||||
"resolved": "https://registry.npmjs.org/aws4/-/aws4-1.8.0.tgz",
|
"resolved": "https://registry.npmjs.org/aws4/-/aws4-1.8.0.tgz",
|
||||||
"integrity": "sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ=="
|
"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": {
|
"babel-jest": {
|
||||||
"version": "24.1.0",
|
"version": "24.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/babel-jest/-/babel-jest-24.1.0.tgz",
|
"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",
|
"resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz",
|
||||||
"integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A=="
|
"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": {
|
"busboy": {
|
||||||
"version": "0.2.14",
|
"version": "0.2.14",
|
||||||
"resolved": "https://registry.npmjs.org/busboy/-/busboy-0.2.14.tgz",
|
"resolved": "https://registry.npmjs.org/busboy/-/busboy-0.2.14.tgz",
|
||||||
@ -1144,7 +1079,8 @@
|
|||||||
"version": "2.17.1",
|
"version": "2.17.1",
|
||||||
"resolved": "https://registry.npmjs.org/commander/-/commander-2.17.1.tgz",
|
"resolved": "https://registry.npmjs.org/commander/-/commander-2.17.1.tgz",
|
||||||
"integrity": "sha512-wPMUt6FnH2yzG95SA6mzjQOEKUU3aLaDEmzs1ti+1E9h+CsrZghRlqEM/EJ4KscsQVG8uNN4uVreUeT8+drlgg==",
|
"integrity": "sha512-wPMUt6FnH2yzG95SA6mzjQOEKUU3aLaDEmzs1ti+1E9h+CsrZghRlqEM/EJ4KscsQVG8uNN4uVreUeT8+drlgg==",
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
},
|
},
|
||||||
"compare-versions": {
|
"compare-versions": {
|
||||||
"version": "3.4.0",
|
"version": "3.4.0",
|
||||||
@ -2866,23 +2802,6 @@
|
|||||||
"function-bind": "^1.1.1"
|
"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": {
|
"has-flag": {
|
||||||
"version": "3.0.0",
|
"version": "3.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz",
|
||||||
@ -6110,47 +6029,11 @@
|
|||||||
"yn": "^3.0.0"
|
"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": {
|
"tsscmp": {
|
||||||
"version": "1.0.6",
|
"version": "1.0.6",
|
||||||
"resolved": "https://registry.npmjs.org/tsscmp/-/tsscmp-1.0.6.tgz",
|
"resolved": "https://registry.npmjs.org/tsscmp/-/tsscmp-1.0.6.tgz",
|
||||||
"integrity": "sha512-LxhtAkPDTkVCMQjt2h6eBVY28KCjikZqZfMcC15YBeNjkgUpdCfBu5HoiOTDu86v6smE8yOjyEktJ8hlbANHQA=="
|
"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": {
|
"tunnel-agent": {
|
||||||
"version": "0.6.0",
|
"version": "0.6.0",
|
||||||
"resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz",
|
"resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz",
|
||||||
@ -6193,12 +6076,6 @@
|
|||||||
"resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz",
|
"resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz",
|
||||||
"integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c="
|
"integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c="
|
||||||
},
|
},
|
||||||
"typescript": {
|
|
||||||
"version": "3.3.3333",
|
|
||||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.3.3333.tgz",
|
|
||||||
"integrity": "sha512-JjSKsAfuHBE/fB2oZ8NxtRTk5iGcg6hkYXMnZ3Wc+b2RSqejEqTaem11mHASMnFilHrax3sLK0GDzcJrekZYLw==",
|
|
||||||
"dev": true
|
|
||||||
},
|
|
||||||
"uglify-js": {
|
"uglify-js": {
|
||||||
"version": "3.4.9",
|
"version": "3.4.9",
|
||||||
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.4.9.tgz",
|
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.4.9.tgz",
|
||||||
|
@ -1,19 +1,15 @@
|
|||||||
{
|
{
|
||||||
"name": "backend",
|
"name": "commons-marketplace-server",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "index.js",
|
"main": "dist/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "npm run serve",
|
"start": "node dist/index.js",
|
||||||
"start-watch": "nodemon",
|
"start-watch": "nodemon",
|
||||||
"build": "npm run build-ts && npm run tslint",
|
"build": "tsc",
|
||||||
"watch": "npm run watch-ts",
|
"watch": "tsc -w",
|
||||||
"serve": "node dist/index.js",
|
|
||||||
"test": "jest --coverage",
|
"test": "jest --coverage",
|
||||||
"watch-test": "npm run test --watchAll",
|
"watch-test": "npm run test --watchAll"
|
||||||
"build-ts": "tsc",
|
|
||||||
"watch-ts": "tsc -w",
|
|
||||||
"tslint": "tslint -c tslint.json -p tsconfig.json"
|
|
||||||
},
|
},
|
||||||
"author": "",
|
"author": "",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
@ -47,9 +43,7 @@
|
|||||||
"nodemon": "^1.18.10",
|
"nodemon": "^1.18.10",
|
||||||
"supertest": "^3.4.2",
|
"supertest": "^3.4.2",
|
||||||
"ts-jest": "^24.0.0",
|
"ts-jest": "^24.0.0",
|
||||||
"ts-node": "^8.0.2",
|
"ts-node": "^8.0.2"
|
||||||
"tslint": "^5.12.1",
|
|
||||||
"typescript": "^3.3.3"
|
|
||||||
},
|
},
|
||||||
"jest": {
|
"jest": {
|
||||||
"preset": "ts-jest"
|
"preset": "ts-jest"
|
||||||
|
@ -2,4 +2,4 @@ module.exports = {
|
|||||||
app: {
|
app: {
|
||||||
port: 4000
|
port: 4000
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
@ -1,58 +1,64 @@
|
|||||||
import debug from "debug";
|
import debug from 'debug'
|
||||||
import express from "express";
|
import express from 'express'
|
||||||
import compression from "compression";
|
import compression from 'compression'
|
||||||
import morgan from "morgan";
|
import morgan from 'morgan'
|
||||||
import bodyParser from "body-parser";
|
import bodyParser from 'body-parser'
|
||||||
|
|
||||||
// routes
|
// routes
|
||||||
import UrlCheckRouter from "./routes/UrlCheckRouter";
|
import UrlCheckRouter from './routes/UrlCheckRouter'
|
||||||
|
|
||||||
// config
|
// config
|
||||||
const config = require("./config/config");
|
const config = require('./config/config')
|
||||||
|
|
||||||
// debug
|
// debug
|
||||||
const log = debug("server:index");
|
const log = debug('server:index')
|
||||||
|
|
||||||
const app = express();
|
const app = express()
|
||||||
app.use((req, res, next) => {
|
app.use((req, res, next) => {
|
||||||
res.header("Access-Control-Allow-Origin", "*");
|
res.header('Access-Control-Allow-Origin', '*')
|
||||||
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, Authorization");
|
res.header(
|
||||||
res.header("Access-Control-Allow-Methods", "GET, POST, OPTIONS, PUT, DELETE");
|
'Access-Control-Allow-Headers',
|
||||||
next();
|
'Origin, X-Requested-With, Content-Type, Accept, Authorization'
|
||||||
});
|
)
|
||||||
app.use(morgan("dev"));
|
res.header(
|
||||||
app.use(bodyParser.json());
|
'Access-Control-Allow-Methods',
|
||||||
app.use(bodyParser.urlencoded({ extended: false }));
|
'GET, POST, OPTIONS, PUT, DELETE'
|
||||||
app.use(compression());
|
)
|
||||||
|
next()
|
||||||
|
})
|
||||||
|
app.use(morgan('dev'))
|
||||||
|
app.use(bodyParser.json())
|
||||||
|
app.use(bodyParser.urlencoded({ extended: false }))
|
||||||
|
app.use(compression())
|
||||||
// routes
|
// routes
|
||||||
app.use("/api/v1/urlcheck", UrlCheckRouter);
|
app.use('/api/v1/urlcheck', UrlCheckRouter)
|
||||||
/// catch 404
|
/// catch 404
|
||||||
app.use((req, res, next) => {
|
app.use((req, res, next) => {
|
||||||
res.status(404).send();
|
res.status(404).send()
|
||||||
});
|
})
|
||||||
// listen
|
// listen
|
||||||
const server = app.listen(config.app.port);
|
const server = app.listen(config.app.port)
|
||||||
server.on("listening", onListening);
|
server.on('listening', onListening)
|
||||||
server.on("error", onError);
|
server.on('error', onError)
|
||||||
|
|
||||||
function onListening(): void {
|
function onListening(): void {
|
||||||
log("Server thread started");
|
log('Server thread started')
|
||||||
}
|
}
|
||||||
|
|
||||||
function onError(error: NodeJS.ErrnoException): void {
|
function onError(error: NodeJS.ErrnoException): void {
|
||||||
if (error.syscall !== "listen") throw error;
|
if (error.syscall !== 'listen') throw error
|
||||||
switch (error.code) {
|
switch (error.code) {
|
||||||
case "EACCES":
|
case 'EACCES':
|
||||||
log("Required elevated privileges");
|
log('Required elevated privileges')
|
||||||
process.exit(1);
|
process.exit(1)
|
||||||
break;
|
break
|
||||||
case "EADDRINUSE":
|
case 'EADDRINUSE':
|
||||||
log("Port is already in use");
|
log('Port is already in use')
|
||||||
process.exit(1);
|
process.exit(1)
|
||||||
break;
|
break
|
||||||
default:
|
default:
|
||||||
throw error;
|
throw error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default server;
|
export default server
|
||||||
|
@ -1,45 +1,50 @@
|
|||||||
import { Router, Request, Response, NextFunction } from "express";
|
import { Router, Request, Response, NextFunction } from 'express'
|
||||||
import request from "request";
|
import request from 'request'
|
||||||
|
|
||||||
export class UrlCheckRouter {
|
export class UrlCheckRouter {
|
||||||
router: Router;
|
router: Router
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the UrlCheckRouter
|
* Initialize the UrlCheckRouter
|
||||||
*/
|
*/
|
||||||
constructor() {
|
constructor() {
|
||||||
this.router = Router();
|
this.router = Router()
|
||||||
}
|
}
|
||||||
|
|
||||||
public checkUrl(req: Request, res: Response, next: NextFunction) {
|
public checkUrl(req: Request, res: Response, next: NextFunction) {
|
||||||
if (!req.body.url) {
|
if (!req.body.url) {
|
||||||
return res.send({ status: "error", message: "missing url" });
|
return res.send({ status: 'error', message: 'missing url' })
|
||||||
}
|
}
|
||||||
request(
|
request(
|
||||||
{
|
{
|
||||||
method: "HEAD",
|
method: 'HEAD',
|
||||||
url: req.body.url,
|
url: req.body.url,
|
||||||
headers: { Range: "bytes=0-" }
|
headers: { Range: 'bytes=0-' }
|
||||||
},
|
},
|
||||||
(error, response) => {
|
(error, response) => {
|
||||||
if (response.statusCode.toString().startsWith("2")) {
|
if (response.statusCode.toString().startsWith('2')) {
|
||||||
const result: any = {};
|
const result: any = {}
|
||||||
result.found = true;
|
result.found = true
|
||||||
if (response.headers["content-length"]) {
|
if (response.headers['content-length']) {
|
||||||
result.contentLength = response.headers["content-length"];
|
result.contentLength =
|
||||||
|
response.headers['content-length']
|
||||||
}
|
}
|
||||||
if (response.headers["content-type"]) {
|
if (response.headers['content-type']) {
|
||||||
const typeAndCharset = response.headers["content-type"].split(";");
|
const typeAndCharset = response.headers[
|
||||||
result.contentType = typeAndCharset[0];
|
'content-type'
|
||||||
|
].split(';')
|
||||||
|
result.contentType = typeAndCharset[0]
|
||||||
if (typeAndCharset[1]) {
|
if (typeAndCharset[1]) {
|
||||||
result.contentCharset = typeAndCharset[1].split("=")[1];
|
result.contentCharset = typeAndCharset[1].split(
|
||||||
|
'='
|
||||||
|
)[1]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return res.send({ status: "success", result: result });
|
return res.send({ status: 'success', result: result })
|
||||||
}
|
}
|
||||||
return res.send({ status: "error", message: error });
|
return res.send({ status: 'error', message: error })
|
||||||
}
|
}
|
||||||
);
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -47,12 +52,12 @@ export class UrlCheckRouter {
|
|||||||
* endpoints.
|
* endpoints.
|
||||||
*/
|
*/
|
||||||
init() {
|
init() {
|
||||||
this.router.post("/", this.checkUrl);
|
this.router.post('/', this.checkUrl)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the MeRouter, and export its configured Express.Router
|
// Create the MeRouter, and export its configured Express.Router
|
||||||
const urlCheckRoutes = new UrlCheckRouter();
|
const urlCheckRoutes = new UrlCheckRouter()
|
||||||
urlCheckRoutes.init();
|
urlCheckRoutes.init()
|
||||||
|
|
||||||
export default urlCheckRoutes.router;
|
export default urlCheckRoutes.router
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
import request from "supertest";
|
import request from 'supertest'
|
||||||
import server from "../src";
|
import server from '../src'
|
||||||
import {} from "jasmine";
|
import {} from 'jasmine'
|
||||||
|
|
||||||
afterAll((done) => {
|
afterAll(done => {
|
||||||
server.close(done);
|
server.close(done)
|
||||||
});
|
})
|
||||||
|
|
||||||
describe("POST /api/v1/urlcheck", () => {
|
describe('POST /api/v1/urlcheck', () => {
|
||||||
it('responds with json', function(done) {
|
it('responds with json', function(done) {
|
||||||
request(server)
|
request(server)
|
||||||
.post('/api/v1/urlcheck')
|
.post('/api/v1/urlcheck')
|
||||||
.expect(200, done);
|
.expect(200, done)
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
|
@ -9,17 +9,10 @@
|
|||||||
"outDir": "dist",
|
"outDir": "dist",
|
||||||
"baseUrl": ".",
|
"baseUrl": ".",
|
||||||
"paths": {
|
"paths": {
|
||||||
"*": [
|
"*": ["node_modules/*", "src/types/*"]
|
||||||
"node_modules/*",
|
|
||||||
"src/types/*"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"types": ["node"],
|
"types": ["node"],
|
||||||
"typeRoots": [
|
"typeRoots": ["node_modules/@types"]
|
||||||
"node_modules/@types"
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
"include": [
|
"include": ["src/**/*"]
|
||||||
"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