Code Monkey home page Code Monkey logo

capiv2-strapi's Introduction

1. Canonn API v2 - (CAPIv2)

Strapi Version CAPIv2 Version Build Status EDCD Discord Canonn Discord

2. Table of Contents

3. Intro

The Canonn APIv2 is designed to handle all our current science projects. Currently the following sites are planned to be implemented in the initial version:

  • Amphora Plants (AP)
    • AP Types
  • Bark Mounds (BM)
    • BM Types
  • Brain Trees (BT)
    • BT Types
  • Crystalline Shards (CS)
    • CS Types
  • Fungal Gourds (FG)
    • FG Types
  • Fumaroles (FM)
    • FM Types
  • Generation Ships (GEN)
    • GEN Logs
  • Guardian Beacons (GB)
    • GB Messages
  • Guardian Ruins (GR)
    • GR Active Obelisks
    • GR Active Groups
    • GR Artifacts
    • GR Codex Categories
    • GR Codex Data
    • GR Obelisks
    • GR Obelisk Groups
    • GR Types
  • Guardian Structures (GS)
    • GS Active Obelisks
    • GS Active Groups
    • GS Artifacts
    • GS Codex Categories
    • GS Codex Data
    • GS Obelisks
    • GS Obelisk Groups
    • GS Types
  • Gas Vents (GV)
    • GV Types
  • Geysers (GY)
    • GY Types
  • Lava Spouts (LS)
    • LS types
  • Thargoid Barnacles (TB)
    • TB Cycles
    • TB Types
  • Thargoid Structures (TS)
    • TS Status
  • Tubeworms (TW)
    • TW Types

Also we are tracking the following:

  • Regions
  • Systems
    • X/Y/Z and Locked status pulled from EDSM
  • Bodies
    • Atmosphere composition (From EDSM)
    • Material composition (From EDSM)
    • All other body metrics (From EDSM)
  • Rings (Currently don't have any use, but in case future data is needed)
  • CMDRs

3.1. Current Version

The current version of the CAPIv2 can be seen at the top of this read me and the CAPIv2 is still in active development and testing. If you would like to contribute please PM DMehaffy on discord DMehaffy#1337

4. API Documentation

Our Swagger docs are auto-generated by our API, each environment (Production, Staging, Development) have their own docs based on the release version.

Development Staging Production

We are also working on our actual documentation to help navigate and describe how our API works, you can take a look at our early preview. You may also help keep our docs up to date in this repo.

5. Prerequisites

You will need the following:

  • Ubuntu 20.04 LTS
  • Git
  • Node v12 or v14
  • NPM v6
  • Yarn
  • Node PM2 (For running API as a service)
  • MariaDB 10.5

5.1. Installing Git, Node v12, and NPM v6

First add the NodeJS Apt repos:

curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -

Then install Git, Node, and NPM:

sudo apt-get install -y nodejs git build-essential libpng-dev

5.2. Install PM2 to run as a service

Run the following to install PM2 globally on your system:

npm install -g pm2

NOTE: If you get an EACCESS error while trying to install global packages, please see this node help guide.

5.3. Install Yarn for development and building

Run the following to install Yarn globally:

npm install -g yarn

5.4. Setup MariaDB

Install Software Properties Common if its not already installed:

sudo apt-get install -y software-properties-common

Then add the MariaDB Apt repos:

sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8

sudo add-apt-repository 'deb [arch=amd64,i386,ppc64el] http://nyc2.mirrors.digitalocean.com/mariadb/repo/10.5/ubuntu xenial main'

Update your apt cache and install the server and client:

sudo apt update
sudo apt install -y mariadb-server-10.5 mariadb-client-10.5

Note that as of MariaDB 10.5 it no longer asks for the root password

To change the MariaDB root password you will need to su to the local root account, enter a mysql shell, and change it:

sudo -i
*asks for password*

mysql -u root -p
USE mysql;
UPDATE user SET password=PASSWORD('YourPasswordHere') WHERE User='root' AND Host = 'localhost';
FLUSH PRIVILEGES;
exit;
exit

6. Create Database & User for Strapi

Now we need to create the databases that will hold the Strapi data, first enter a mysql shell as root:

mysql -u root -p

You will need two databases, as we split the users data into it's own DB to allow for easy access between production, staging, and development

Create the data and user databases and a user to access them:

create database capiv2_data;
create database capiv2_user;
create user 'capiv2system'@'localhost' identified by 'YourPasswordHere';
grant all privileges on capiv2_data.* to 'capiv2system'@'localhost';
grant all privileges on capiv2_user.* to 'capiv2system'@'localhost';

After this you should have the following databases capiv2_data & capiv2_user with the user capiv2system and a password for use with Strapi.

7. Clone the CAPIv2-Strapi project and Setup

Now that we have the database we can clone the API and install it, we will use /srv/CAPIv2 but you can install it anywhere.

7.1. Clone the API

Lets create our project directory and clone the CAPIv2 Build

sudo mkdir /srv/CAPIv2 && sudo chown YourUserName:YourUserGroup /srv/CAPIv2

cd /srv/CAPIv2 && git clone https://github.com/canonn-science/CAPIv2-Strapi.git

NOTE Currently you will need to make the uploads directory for screenshots, to do so please run:

mkdir /srv/CAPIv2/CAPIv2-Strapi/public/uploads

7.2. Enter the directory and install

cd /srv/CAPIv2/CAPIv2-Strapi && yarn install

Note this may take a while

7.3. Create the .env file to setup the database access

In order for strapi to talk to the MariaDB database we setup you will need to copy and modify the following file:

NOTE: This may not work on windows, if you are on a windows machine you will need to declare the variables on the commandline!

cp /srv/CAPIv2/CAPIv2-Strapi/.env.example /srv/CAPIv2/CAPIv2-Strapi/.env

The example config is also down below, you will just need to modify the Database, User, and password you setup:

You will need to set the Database settings for User and development at a minimum, you can leave the JWT Secret the same as we provide exports of some sample users.

For the Discord webhook, you will need to create a Discord Server and setup a webhook URL. This webhook is a work in progress but will be used to provide alerts when certain data is added.

7.4. Building the CAPIv2 Admin Panel

With the new Strapi versions, we can now customize and rebuild the AdminUI to our liking as such when you clone the project you will need to build this AdminUI as we do not keep it in git.

To build simply run yarn build

7.5. Start CAPIv2 for the first time

Once it has finished setting up, you can start it once in order to create your admin user:

cd /srv/CAPIv2/CAPIv2-Strapi && yarn start

7.6. Create the Admin User

After strapi has started you can visit http://localhost:1337/admin if you are on the machine, else you can change localhost to your servers IP.

7.7. Running CAPIv2 as a service

To run strapi as a service, a change was made in the package.json, and you have installed PM2 in a previous step. You will need to navigate to the directory the API is cloned into and run the following:

NODE_ENV=development pm2 start npm --name="capiv2" -i 1 -- run start

Alternatively you can modify the NODE_ENV for staging or production use. Again if you are on a windows machine you may need to define the database and JWT secret environment variables, just like what is being done with NODE_ENV.

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.