Giter Club home page Giter Club logo

alienworlds-api's Introduction

Alien Worlds API

API to index and read Alien Worlds data

Visual Source

First Time Installation & Configuration

Please read & follow the steps before first installation

Installation Steps

  1. Install Docker if you haven't done so brew install docker or download it from the official docker website.
  2. Fork the repository on Github, and clone it locally
    git clone <your-git-account>/alienworlds-api.git
    cd alienworlds-api
  3. Edit local configuration (consult with an engineer from the team if needed)
    • Edit config.js
    • Copy .env.example to .env & configure as needed.
  4. Build all docker images, download all dependencies + initialize database
    docker compose build
    docker compose run api yarn
    docker compose run api yarn build
    docker compose run api yarn abis
    docker compose run api yarn mongo-indexes
    docker compose run api yarn husky
    Hint: each command is individually documented below the "Commands List" section.
  5. Start all services -> the API will be accessible at localhost:8080
    docker compose up

Commands List

Running

Editing files in src folder will automatically recompile & reload changes is running services.

docker compose up

Manual Procedures

Rebuild All Docker Containers Locally

This command will build all docker containers (each service runs in a separated container) locally. Hint: Advanced use: Use docker CLI to log in to ghcr.io to access remote cached versions of the containers for faster startup. This is optional for local development - used by the CI.

docker compose build

Download all Node Dependencies

This must be run every time when package.json changes. It will download all node dependencies into the node_modules folder.

docker compose run api yarn

Build All Alien World Services

Specific build command to initialize Alien World related configurations.

docker compose run api yarn build

Fetch ABIs

This must be redone when the ABI changes.

docker compose run api yarn abis

Setup Mongo Indexes

Only need to be run once, to set up the indexes in MongoDB.

docker compose run api yarn mongo-indexes

Maintenance

Install Git Pre-commit Hooks

Husky is a utility to automatically set up Git Hooks for local development.

docker compose run api yarn husky

Style check

We're using ESLint & Prettier for sanity & style check. The following command win run both at once. Once Husky is initialized, these checks will run automatically before every commit & push.

docker compose run api yarn lint

Style auto fix

The following command will attempt to fix all lint & style issues automatically.

docker compose run api yarn lint-fix

Shell

The following command will let you log in inside the API container. The container contains an alpine linux with the exact required node & npm installations. Logging into the container can help debugging and you can also use all the tools required to run the app right inside the container, without even installing it on your own host machine. Please always use yarn instead of npm to maintain yarn.lock file integrity.

docker compose run api sh

Uploading Compiled docker images to Docker registry

This command will upload all docker containers to the given registry. The registry is defined in the .env file, by default it's Github's Container registry: DOCKER_REGISTRY=ghcr.io/alien-worlds This command is normally part of the CI process. To make it work you must log in to the docker registry first. More information about how to login to Github's Docker registry with docker using the CLI and a Personal Access Token, please read the official documentation.

docker compose push

Pulling the latest compiled images from Docker repository

This command is part of the CI chain and normally don't need to run locally. Requires a successful docker login to the registry first (please read the official documentation), then you can pull the images (instead of building locally).

docker compose pull

API Access

alienworlds-api's People

Contributors

angelol avatar dallasjohnson avatar dskvr avatar ktamas77 avatar michaeljyeates avatar montera82 avatar rkamysz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

alienworlds-api's Issues

Mines endpoint limit query parameter

I've found that setting the query parameter of limit to 2 will result in this error.

{ "statusCode": 500, "error": "Internal Server Error", "message": "Limit maximum is 5000" }

I've tried a limit value of 0,1,3, and 4 and they all have worked no problem.

Job is stuck

Appears a job is stuck. I can definitely push a commit to the PR to try and trigger it again, but it's a good opportunity to try and figure out what happened. We originally thought it was because the PR was a draft status, but did not resolve itself when marked as "Ready for Review"

See #35

Improve readme file - following main readme leads into mongo container issues

Type

Documentation Enhancement

What is the motivation behind this improvement?

Following the guidelines included into the readme, apparently leads to issue on mongo db container set up

docker-compose build
docker-compose run api yarn
docker-compose run api yarn build
docker-compose run api yarn abis
docker-compose run api yarn mongo-indexes <-- here
docker-compose run api yarn husky

Docker compose stops with error and docker container alienworlds-api_db_1 continues restarting

Failed to connect
 MongoServerSelectionError: getaddrinfo EAI_AGAIN db
    at Timeout._onTimeout (/var/www/api/node_modules/mongodb/lib/core/sdam/topology.js:438:30)
    at listOnTimeout (node:internal/timers:568:17)
    at processTimers (node:internal/timers:510:7) {
  reason: TopologyDescription {
    type: 'Single',
    setName: null,
    maxSetVersion: null,
    maxElectionId: null,
    servers: Map(1) { 'db:27017' => [ServerDescription] },
    stale: false,
    compatible: true,
    compatibilityError: null,
    logicalSessionTimeoutMinutes: null,
    heartbeatFrequencyMS: 10000,
    localThresholdMS: 15,
    commonWireVersion: null
  }
}
node:internal/process/promises:246
          triggerUncaughtException(err, true /* fromPromise */);
          ^

MongoServerSelectionError: getaddrinfo EAI_AGAIN db
    at Timeout._onTimeout (/var/www/api/node_modules/mongodb/lib/core/sdam/topology.js:438:30)
    at listOnTimeout (node:internal/timers:568:17)
    at processTimers (node:internal/timers:510:7) {
  reason: TopologyDescription {
    type: 'Single',
    setName: null,
    maxSetVersion: null,
    maxElectionId: null,
    servers: Map(1) {
      'db:27017' => ServerDescription {
        address: 'db:27017',
        error: Error: getaddrinfo EAI_AGAIN db
            at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:72:26) {
          name: 'MongoNetworkError'
        },
        roundTripTime: -1,
        lastUpdateTime: 595462,
        lastWriteDate: null,
        opTime: null,
        type: 'Unknown',
        topologyVersion: undefined,
        minWireVersion: 0,
        maxWireVersion: 0,
        hosts: [],
        passives: [],
        arbiters: [],
        tags: []
      }
    },
    stale: false,
    compatible: true,
    compatibilityError: null,
    logicalSessionTimeoutMinutes: null,
    heartbeatFrequencyMS: 10000,
    localThresholdMS: 15,
    commonWireVersion: null
  }
}

Describe your Improvement

Include a better description on how run the proper docker compose process and or edits configurations files.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.