All Projects → testnet-exchange → testnet.backend

testnet-exchange / testnet.backend

Licence: Apache-2.0 license
Backend for a ViaBTC exchange server (trading engine)

Programming Languages

javascript
184084 projects - #8 most used programming language
Dockerfile
14818 projects

Projects that are alternatives of or similar to testnet.backend

frontend
testnet.exchange frontend
Stars: ✭ 18 (+0%)
Mutual labels:  exchange, testnet, viabtc
python-viabtc-api
API Wrapper for ViaBTC exchange server
Stars: ✭ 39 (+116.67%)
Mutual labels:  exchange, viabtc
viabtc exchange server
A high performance and real time quotation push trade engine.
Stars: ✭ 35 (+94.44%)
Mutual labels:  exchange, viabtc
py-etherdelta
Python client for interacting with the EtherDelta API and Smart Contracts.
Stars: ✭ 22 (+22.22%)
Mutual labels:  exchange
binance-signature-examples
Examples of generating HMAC and RSA signature for Binance API
Stars: ✭ 170 (+844.44%)
Mutual labels:  exchange
cryptomkt-node
CryptoMarket Node SDK
Stars: ✭ 21 (+16.67%)
Mutual labels:  exchange
fotongo
Simple boilerplate for building Backend services like ExpressJS with GOFIBER ⚡️
Stars: ✭ 29 (+61.11%)
Mutual labels:  backend
vagas
🤝 Venha fazer parte do nosso time
Stars: ✭ 15 (-16.67%)
Mutual labels:  backend
blockchain c2c
A Proof of Concept to show how blockchain can solve C2C persistence. PoC originally presented at EuskalHack Security Congress 2017, updated and improved for Cybercamp 2017.
Stars: ✭ 21 (+16.67%)
Mutual labels:  testnet
parse-react
[EXPERIMENTAL] React, React Native, and React with SSR (e.g. Next.js) packages to interact with Parse Server backend
Stars: ✭ 58 (+222.22%)
Mutual labels:  backend
deno-pokemon
a simple api to create and explore pokemons - made with oak deno framework
Stars: ✭ 20 (+11.11%)
Mutual labels:  backend
kontenbase
Kontenbase is a no code backend API platform / Backend as a Service (BaaS)
Stars: ✭ 98 (+444.44%)
Mutual labels:  backend
awesome-backend
Curadoria de conteúdos relacionados à backend.
Stars: ✭ 158 (+777.78%)
Mutual labels:  backend
oso-backend
Heart of the oso project.
Stars: ✭ 12 (-33.33%)
Mutual labels:  backend
vaahcms
VaahCMS is a laravel based open-source web application development platform shipped with a headless content management system (CMS).
Stars: ✭ 56 (+211.11%)
Mutual labels:  backend
alpha-interface
✨ Token Exchange App for Arweave Profit Sharing Tokens
Stars: ✭ 34 (+88.89%)
Mutual labels:  exchange
idex-sdk-js
IDEX v3 SDK built with TypeScript, supporting both web and Node environments.
Stars: ✭ 35 (+94.44%)
Mutual labels:  exchange
ssb-minimal
A minimal way to get started talking to ssb on a testnet in node
Stars: ✭ 14 (-22.22%)
Mutual labels:  testnet
content defender
Define allowed or denied content element types in your backend layouts
Stars: ✭ 63 (+250%)
Mutual labels:  backend
binance-client-websocket
🛠️ C# client for Binance websocket API
Stars: ✭ 41 (+127.78%)
Mutual labels:  exchange

Backend for testnet.exchange

The backend for ViaBTC-powered opensource cryptocurrency exchange.

A RESTful API generated by generator-rest.

See the API's documentation.

Commands

After you generate your project, these commands are available in package.json.

npm test # test using Jest
npm run coverage # test and open the coverage report in the browser
npm run lint # lint using ESLint
npm run dev # run the API in development mode
npm run prod # run the API in production mode
npm run docs # generate API docs

Docker

docker build .
docker run [image-id]

Playing locally

First, you will need to install and run MongoDB in another terminal instance.

$ mongod

Then, run the server in development mode.

$ npm run dev
Express server listening on http://0.0.0.0:9000, in development mode

If you choose to generate the authentication API, you can start to play with it.

Note that creating and authenticating users needs a master key (which is defined in the .env file)

Create a user (sign up):

curl -X POST http://0.0.0.0:9000/users -i -d "[email protected]&password=123456&access_token=MASTER_KEY_HERE"

It will return something like:

HTTP/1.1 201 Created
...
{
  "id": "57d8160eabfa186c7887a8d3",
  "name": "test",
  "picture":"https://gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?d=identicon",
  "email": "[email protected]",
  "createdAt": "2016-09-13T15:06:54.633Z"
}

Authenticate the user (sign in):

curl -X POST http://0.0.0.0:9000/auth -i -u [email protected]:123456 -d "access_token=MASTER_KEY_HERE"

It will return something like:

HTTP/1.1 201 Created
...
{
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9",
  "user": {
    "id": "57d8160eabfa186c7887a8d3",
    "name": "test",
    "picture": "https://gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?d=identicon",
    "email": "[email protected]",
    "createdAt":"2016-09-13T15:06:54.633Z"
  }
}

Now you can use the eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9 token (it's usually greater than this) to call user protected APIs. For example, you can create a new article API using yo rest:api and make the POST /articles endpoint only accessible to authenticated users. Then, to create a new article you must pass the access_token parameter.

curl -X POST http://0.0.0.0:9000/articles -i -d "title=Awesome Article&content=Yeah Baby&access_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9"

It will return something like:

HTTP/1.1 201 Created
...
{
  "id": "57d819bfabfa186c7887a8d6",
  "title": "Awesome Article",
  "content": "Yeah Baby",
  "createdAt": "2016-09-13T15:22:39.846Z",
  "updatedAt":"2016-09-13T15:22:39.846Z"
}

Some endpoints are only accessible by admin users. To create an admin user, just pass the role=admin along to other data when calling POST /users.

Deploy

Here is an example on how to deploy to Heroku using Heroku CLI:

# start a new local git repository
git init

# create a new heroku app
heroku apps:create my-new-app

# add heroku remote reference to the local repository
heroku git:remote --app my-new-app

# add the MongoLab addon to the heroku app
heroku addons:create mongolab

# set the environment variables to the heroku app (see the .env file in root directory)
heroku config:set MASTER_KEY=masterKey JWT_SECRET=jwtSecret

# commit and push the files
git add -A
git commit -m "Initial commit"
git push heroku master

# open the deployed app in the browser
heroku open

The second time you deploy, you just need to:

git add -A
git commit -m "Update code"
git push heroku master

Directory structure

Overview

You can customize the src and api directories.

src/
├─ api/
│  ├─ user/
│  │  ├─ controller.js
│  │  ├─ index.js
│  │  ├─ index.test.js
│  │  ├─ model.js
│  │  └─ model.test.js
│  └─ index.js
├─ services/
│  ├─ express/
│  ├─ facebook/
│  ├─ mongoose/
│  ├─ passport/
│  ├─ sendgrid/
│  └─ your-service/
├─ app.js
├─ config.js
└─ index.js

src/api/

Here is where the API endpoints are defined. Each API has its own folder.

src/api/some-endpoint/model.js

It defines the Mongoose schema and model for the API endpoint. Any changes to the data model should be done here.

src/api/some-endpoint/controller.js

This is the API controller file. It defines the main router middlewares which use the API model.

src/api/some-endpoint/index.js

This is the entry file of the API. It defines the routes using, along other middlewares (like session, validation etc.), the middlewares defined in the some-endpoint.controller.js file.

services/

Here you can put helpers, libraries and other types of modules which you want to use in your APIs.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].