From febd83dc8843e06f779439429f19de8de711c79f Mon Sep 17 00:00:00 2001 From: Jernej Pregelj Date: Wed, 17 Apr 2019 16:13:49 +0200 Subject: [PATCH] server api readme --- server/README.md | 139 +++++++++++++++++++++++++++++++++++++++++++ server/src/server.ts | 4 +- 2 files changed, 141 insertions(+), 2 deletions(-) create mode 100644 server/README.md diff --git a/server/README.md b/server/README.md new file mode 100644 index 0000000..5705457 --- /dev/null +++ b/server/README.md @@ -0,0 +1,139 @@ +[![banner](https://raw.githubusercontent.com/oceanprotocol/art/master/github/repo-banner%402x.png)](https://oceanprotocol.com) + +

Commons: Server

+ +## Introduction + +This folder contains server component written in TypeScript using [Express](https://expressjs.com). The server provides various microservices, like remote file checking, retiring and updating metadata. + +To spin up the server in a watch mode for local development, execute: + +```bash +npm install +npm start +``` + +## ✨ API Documentation + +### 1. Url Checker + +Url Checker returns if file exists, size and additional information about requested file. This service is used as a solution to frontend CORS restrictions. + +**Endpoint:** POST `/api/v1/urlcheck` + +**Input Parameters:** + +```json +{ + "url": "https://oceanprotocol.com/tech-whitepaper.pdf" +} +``` + +**Return Value** + +```json +{ + "status": "success", + "result": { + "found": true, + "contentLength": "2989228", + "contentType": "application/pdf" + } +} +``` + +**Return Value (file not found)** + +```json +{ + "status": "error", + "message": null +} +``` + +### 2. Retire asset + +Retires asset from Commons Marketplace. To verify owner, he needs to sign `You are retiring ` with crypto wallet and send in both signature and did. + +**Endpoint:** POST `/api/v1/retireddo` + +**Input Parameters:** + +```json +{ + "did": "did:op:1e69c2ae7cca4c0e852204443208c12c3aa58bfd67c7451cb1ee770df1dcae2b", + "signature": "`>" +} +``` + +**Return Value** + +```json +{ + "status": "success" +} +``` + +**Return Value (wrong signature)** + +```json +{ + "status": "error", + "message": "Not owner of asset" +} +``` + +### 3. Update asset + +Updates asset on Commons Marketplace. To verify owner, he needs to sign `You are updating ` with crypto wallet and send in both signature and did. + +**Endpoint:** POST `/api/v1/updateddo` + +**Input Parameters:** + +```json +{ + "did": "did:op:1e69c2ae7cca4c0e852204443208c12c3aa58bfd67c7451cb1ee770df1dcae2b", + "metadata": "TBD", + "signature": "`>" +} +``` + +**Return Value** + +```json +{ + "status": "success" +} +``` + +**Return Value (wrong signature)** + +```json +{ + "status": "error", + "message": "Not owner of asset" +} +``` + +## 🎁 Contributing + +See the page titled "[Ways to Contribute](https://docs.oceanprotocol.com/concepts/contributing/)" in the Ocean Protocol documentation. + +## 🏛 License + +```text +Copyright 2018 Ocean Protocol Foundation Ltd. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +``` diff --git a/server/src/server.ts b/server/src/server.ts index f51965e..57289f0 100644 --- a/server/src/server.ts +++ b/server/src/server.ts @@ -53,8 +53,8 @@ app.use(bodyParser.urlencoded({ extended: false })) app.use(compression()) // routes app.use('/api/v1/urlcheck', UrlCheckRouter) -app.use('/api/v1/updateDdo', UpdateRouter) -app.use('/api/v1/retireDdo', RetireRouter) +app.use('/api/v1/updateddo', UpdateRouter) +app.use('/api/v1/retireddo', RetireRouter) /// catch 404 app.use((req, res) => {