digiasset-metadata-server v0.3.1
DigiAssets Metadata Server
REST API server for fetching and sharing DigiAssets transactions metadata. To learn how this repo fits into the DigiAssets stack please read the API docs & wiki.
Getting Started
Installation
$ npm i -g digiasset-metadata-serverRun
Currently, the server uses AWS S3 storage service as a caching layer. So, in order to use the server one needs to set the environment variables:
AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY
AWS_S3_BUCKETThen, you can run the DigiAssets metadata server with the following options:
$ digiasset-metadata-server [options]
Options:
-h, --help output usage information
-V, --version output the version number
-p, --port <port> Port to listen onOr just run it with the defaults using:
$ digiasset-metadata-serverAPI
GET /getMetadata
Query Parameters:
torrentHashhex string of length 40, representing the SHA1 result of the origin metadata torrent filesha2hex string of length 64, the SHA256 result ofJSON.stringify()of the origin metadata
Success Response:
Code: 200 OK Content: The origin metadata JSON
Error Response:
Code: 400 Bad Request Content:
"Can't get metadata"In case no file which correponds to giventorrentHashandsha2is found.
POST /addMetadata
Body Parameters:
metadataJSONtokenJWT encoded by secret given in environment variableJWTTOKENSECRET. Decode is of the format{iss: 'admin', exp: 'expiration'}. IfJWTTOKENSECRETenvironment variable (or corresponding properties file field) is not given, this parameter is ignored.
Success Response:
Code: 200 OK Content: Object which consists of the following:
torrentHashhex string of length 40, representing the SHA1 result of the origin metadata torrent filesha2hex string of length 64, the SHA256 result ofJSON.stringify()of the origin metadata
Error Response:
Code: 401 Unauthorized In case given
tokenis not as expected.
GET /shareMetadata
Query parameters
torrentHashhex string of length 40, representing the SHA1 result of the origin metadata torrent filetokenJWT encoded by secret given in environment variableJWTTOKENSECRET. Decode is of the format{iss: 'admin', exp: 'expiration'}. IfJWTTOKENSECRETenvironment variable (or corresponding properties file field) is not given, this parameter is ignored.
Success Response:
Code: 200 OK Content: The metadata file which has torrent which corresponds to
torrentHash, is seeded to BitTorrent network.Error Response:
Code: 401 Unauthorized In case given
tokenis not as expected.Code: 400 Bad Request Content:
"Can't share metadata"In case no file which corresponds totorrentHashis found.
Note: this call should be preceded by a call to POST /addMetadata
Configuration
Default configuration per environment (NODE_ENV value) can be found in the config directory.
You can use custom properties by adding properties.conf to that folder.
Development
- Fork this repo
- npm install
- use the Standard coding style when hacking the code - https://github.com/feross/standard
- Send us a pull request
Hosted Server
DigiAssets maintains a hosted version of this server at:
https://DigiAssets.net