Skip to content

🌍 Addon registry (like npm but for SlimIO)

License

Notifications You must be signed in to change notification settings

SlimIO/Registry

Repository files navigation

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

About

🌍 Addon registry (like npm but for SlimIO)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published