orion

Config-based API server framework


Project maintained by ctjong Hosted on GitHub Pages — Theme by mattgraham

Orion API

npm npm David

Orion is a framework for creating a config-based REST API server, meaning the client can create a full-fledged API server by only defining a single configuration file. The framework is built on top of Express. The server application that the framework creates will support CRUD, file upload, authentication, and error handling.

Supported components

The framework allows you to use the following services based on your preferences:

Installation

$ npm install --save orion-api

Example usage

config.js

module.exports =
{
    database:
    {
        dialect: "mssql",
        host: _DATABASE_HOST_,
        name: _DATABASE_NAME_,
        userName: _DATABASE_USERNAME_,
        password: _DATABASE_PASSWORD_
    },
    entities:
    {
        "blogpost":
        {
            "fields":
            {
                "title": { type: "string", isEditable: true, isRequired: true, foreignKey: null },
                "content": { type: "richtext", isEditable: true, isRequired: true, foreignKey: null }
            },
            "permissions":
            {
                "read": ["guest"],
                "create": ["guest"],
                "update": ["guest"],
                "delete": ["guest"]
            }
        }
    }
};

server.js

const Orion = require('orion-api');
const config = require('./config');
const orionApp = new Orion(config);
orionApp.setupApiEndpoints();

// to add more endpoints, use orionApp.app like regular Express app:
// orionApp.app.get("/additionalroute", (req, res) => ...);

orionApp.startAsync();

Documentation

Contributing

License