Skip to content

ctjong/orion

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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:

  • Database: SQL Server / MySQL / sqlite
  • File storage: Azure Blob Storage / Amazon S3 / Local Server
  • Authentication: Facebook token / Orion JSON Web Token (JWT)
  • Monitoring: Azure Application Insights

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

Links

Contributing

License