Installation

Requirements

  • node.js & npm
  • java8
  • elasticsearch
  • redis (optional)

Heroku installation

Deploy ItemsAPI instantly to heroku and start your API immediately!

Deploy

Standalone server

# Clone ItemAPI repository from github:
$ git clone git@github.com:itemsapi/itemsapi.git

# Install all node.js packages
$ npm install

# Starting app
$ node app.js

# Starting app with environment variables
$ MONGODB_URL=mongodb-url ELASTICSEARCH_URL=elasticsearch-url REDIS_URL=redis-url PORT=5000 node app.js

# Starting with process manager `pm2`. App will work in background
$ pm2 start app.js

NPM package

# Init project:
$ npm init

# Install itemsapi:
$ npm install itemsapi --save

You can use itemsapi in your node.js app or just start a server in one file

var itemsapi = require('itemsapi');

itemsapi.init({
  server: {
    port: 5000
  },
  collections: {
    db: 'json',
    filename:  './collections.json'
  },
  elasticsearch: {
    host: 'localhost:9200'
  }
})

itemsapi.start(function serverStart(serverInstance) {
  var host = serverInstance.address().address;
  var port = serverInstance.address().port;
  itemsapi.get('logger').info('ItemsAPI backend started on http://%s:%s', host, port)
});

Installation using docker compose

$ git clone https://github.com/itemsapi/itemsapi.git
# go into project directory
$ cd itemsapi
# it will install app on port 3000 i.e. localhost:3000
$ docker-compose up
Was this page helpful ?