Skip to content
REST API themed around Exotic Cars. Backend is MongoDB with Elasticsearch, you know for search!
JavaScript CSS HTML Other
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
api
assets
charts changed to ambassador to expose Feb 10, 2020
config
tasks
views
.bowerrc
.dockerignore
.editorconfig
.gitignore
.helmignore
.sailsrc
Dockerfile
Gruntfile.js
LICENSE
OWNERS
OWNERS_ALIASES
Procfile
README.md
SUMMARY.md
app.js
bower.json
docker-compose.yml
jenkins-x.yml
npm-shrinkwrap.json
package.json
skaffold.yaml
tasks.md

README.md

Cars REST API

Cars REST API

a Sails application that can be used while you test Docker Containers including Orchestration using Kubernetes

This is a sample REST API project based on SailsJS, showcases blueprints, actions and other out of the box capabilities. It also showcases how to use the ELK stack (Elasticsearch, Logstash, Kibana), models have a coordinates field, and therefore you can show cars on the map within Kibana visualizations.

Architecture

The following components are part of the overall solution

  • Cars REST API
  • Search Service (Elasticsearch)
  • MongoDB

API Gateway

Use Apollo for GraphQL API Gateway. All requests are handled by the gateway.

GraphQL Middleware

The Cars API also comes with a custom middleware that can serve GraphQL and respond to queries. This middleware is found under config/http.js You can disable this via the environment variable DISABLE_GRAPHQL and setting that to false.

Search

ElasticSearch is used by a custom SailsJS Hook to be able to index Car and Person objects at creation and update time. This effectively updates the index accordingly.

Swagger API Documentation

The sailsjs-swagger and swagger-ui are used to product the REST API documentation accessible via http://localhost:1337/docs which brings up the Swagger UI

Features

The app comes with various capabilities in terms of deployment.

  • Can can run as a Docker container by using the docker-compose.yaml
  • Can be deployed to a Kubernetes cluster by installing it via helm
  • Enable data seed by setting the DISABLE_SAILS_SEED to false and MongoDB + Elasticsearch (if enabled) will have the initial data.

Environment Variables

NAME DESCRIPTION VALUE
ENABLE_ELASTICSEARCH disables/enables Elasticsearch true
DISABLE_SAILS_SEED Useful if you want to quickly have some sample data false
DISABLE_GRAPHQL true disables the middleware, false enables it false

Secrets

You can create secrets in two different ways.

Option 1 - create a secret based on an .env file, ensure to run the command for each namespace

Create a kubernetes secret based on the values of .env file

kubectl create secret generic mongodb-auth --from-env-file=.env --namespace jx

Option 2 - base64 encode values and paste them in the mongodbsecret.yaml

# create mongodbUsername
>$ echo -n 'admin' | base64

# create mongodbPassword
>$ echo -n 'Password1' | base64
You can’t perform that action at this time.