0.9.9 • Published 17 days ago

objy-platform v0.9.9

Weekly downloads
-
License
MIT
Repository
github
Last release
17 days ago

OBJY Platform

OBJY Platform is a framework for building custom platforms. It comes with everythyng needed for running a platform, like Abstract Object Programming Model, Authorizations, Messaging, User Handling, Multi Tenancy and more.

Install:

npm i objy objy-platform

For running a basic platform you will need Node.js, Redis and MongoDB. This will change in the future.

// 1. import objy and objy-platform
const OBJY = require('objy');
const PLATFORM = require('objy-platform');

// 2. define some "object wrappers"
OBJY.define({
  name: "user",
  pluralName: "users",
  authable: true
})

OBJY.define({
  name: "object",
  pluralName: "objects"
})

// 3. run the platform via REST
PLATFORM.REST({
  port:80,
  OBJY,
  metaMapper: new PLATFORM.metaMappers.mongoMapper().connect("mongodb://localhost") // The matamapper is for basic config
}).run()

Parameters help customizing a platform. Some are reqiured, some are optional. Optional ones have default values as shown below.

PLATFORM.REST({
  // REQUIRED
  OBJY, // OBJY instance
  metaMapper: new SomeMapper() // The matamapper is for basic config
  messageMapper: new MessageMapper, // Mapper that handles messaging
  redisCon: { // Redis connection
      host: '',
      port: '',
      password: '',
      username: '',
  },
  // or redisCon: 'redis://url.com:port'


  // OPTIONAL
  port: 80, // Port to listen on
  publicPlatform: false, // When true, ALL read requests don'T require authentication
  maxUserSessions: 100, // Max concurrent sessions per user
  userPasswordResetMessage: { // Email params when a user resets a password
      from: 'mail@domain.com',
      subject: '',
      body: '',
  },
  clientRegistrationMessage: { // Email params when a client is registered
      from: 'mail@domain.com',
      subject: '',
      body: '',
  },
  userRegistrationMessage: { // Email params when a user is registered
      from: 'mail@domain.com',
      subject: '',
      body: '',
  }
}).run()