Skip to content

Latest commit

 

History

History
328 lines (254 loc) · 7.87 KB

README.md

File metadata and controls

328 lines (254 loc) · 7.87 KB

Registry

version Maintenance MIT dep size Known Vulnerabilities Build Status Greenkeeper badge

Registry is an HTTP API whose main purpose is to manage SlimIO Addons. The API let you create your own account and manage an organisation to publish and edit your personal and/or company addon(s).

This project has been inspired by npm Registry.

Requirements

  • Node.js v12 or higher
  • A local MariaDB database (else setup the project for SQLite).

Getting Started

$ git clone https://github.com/SlimIO/Registry.git
$ cd Registry
$ npm ci
$ npm start

Environment Variables

The server can be configured by setting up environment variables. This project is capable to load these variables from local .env file too.

$ touch .env

Add these environment variables and save them, you can change the values ​​of these keys according to your needs

SECRET_KEY=your_secret_key
PORT=1337

DB_DIALECT=sqlite
DB_NAME=registry
DB_USER=root
DB_PASSWORD=ROOT

Supported DB dialect are: mysql, sqlite, postgres, mssql.

DB Schema

Endpoints

For all request with a body data, you need to set your headers with:

  • Content-Type: application/json
icon description
🔑 ⚠️ You need to be authenticated to use this route: see /login

Meta endpoints

GET ·/

Return service metadata.

Name Value Kind Required? Notes
{
    uptime: 3403
}

User endpoints

POST ·/login

Authenticate a user and get an AccessToken. The account must be activated before to success.

Name Value Kind Required? Notes
username String Body User name
password String Body User password

Return an AccessToken which will be required for some endpoints.

{
    access_token: string;
}
POST ·/users

Create a new inactive user. The account will be deleted after 24 hours if no activation occur.

Name Value Kind Required? Notes
username String Body User name
password String Body User password

Return an empty JSON on success with a code 201.

{}
POST ·/users/activeAccount

Activate an account with the activation token received by email.

Name Value Kind Required? Notes
token String Body Activation token

Return an empty JSON on success with code 200.

{}

Addon endpoints

GET ·/addon

Get all available addons.

Name Value Kind Required? Notes
[
    "cpu",
    "memory"
]
GET ·/addon/{addonName}

Get a given addon by his name.

Name Value Kind Required? Notes
addonName String Path Addon name

Return a data structure described by the following interface:

{
    name: string,
    description: string,
    git: string,
    createdAt: Date,
    updatedAt: Date,
    author: {
        username: string,
        description: string
    },
    organisation: {
        name: string,
        createdAt: Date,
        updatedAt: Date
    },
    versions: [
        {
            version: string,
            createdAt: string
        }
    ]
}
🔑 POST ·/addon/publish

Create or update an Addon release. This endpoint require an AccessToken.

Name Value Kind Required? Notes
name String Body Addon name
description String Body Addon description
version String Body Semver
git String Body GIT Url
organisation String Body Organisation (if any)

Return the addon id.

{
    addonId: 1
}

Organisation endpoints

GET ·/organisation

Get all organisations.

Name Value Kind Required? Notes

Return an JavaScript Object described by the following interface:

{
    [name: string]: {
        description: string,
        owner: string,
        users: string[]
        addons: string[]
    }
}

GET ·/organisation/{name}

Get an organisation by his name.

Name Value Kind Required? Notes
name String Path Organisation name

Return a data structure like:

{
    name: string,
    description: string,
    createdAt: Date,
    updatedAt: Date,
    owner: {
        username: string,
        createdAt: Date,
        updatedAt: Date
    },
    users: [
        {
            username: string,
            createdAt: Date,
            updatedAt: Date
        }
    ]
    addons: [
        {
            name: string,
            description: string,
            git: string,
            createdAt: Date,
            updatedAt: Date
        }
    ]
}

🔑 POST : /organisation/:orgaName/:userName

Add a user to an organisation. This endpoint require an AccessToken.

Name Value Kind Required? Notes
orgaName String Path Organisation name
userName String Path User name

⚠️ Only Organisation owner can use this endpoint.

Return the following interface:

{
    createdAt: date,
    updatedAt: date,
    organisationId: number,
    userId: number
}

Dependencies

Name Refactoring Security Risk Usage
@polka/send-type Minor Low TBC
@slimio/is Minor Low Type Checker
argon2 ⚠️Major High Crypto package
body-parser Minor High Body Parser
dotenv Minor Low Load local .env in process.env
indicative Minor Low Validator
jsonwebtoken ⚠️Major High JWT Token
kleur Minor Low Colors for TTY
make-promises-safe ⚠️Major Medium Force Node.js DEP00018
polka ⚠️Major Low HTTP Server
semver Minor Low SemVer validation
semver-sort Minor Low Sort SemVer versions
sequelize ⚠️Major High ORM
sqlite3 ⚠️Major High SQLite

License

MIT