0.12.2 • Published 2 years ago

minio-cms v0.12.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Minio

Build Status Azure DevOps coverage Azure DevOps tests npm

Minio is an easy to use minimalistic sandbox project providing

  • auth
  • token
  • model
  • security

services with support for customize the special requirements. It's not just another CMS system. It's only a minimalistic bootstrapper providng possibility for customizations.

The main purpose is to providing convenient services in order to automate following features:

  • auth management
  • token management
  • providing model mapping
  • security management
  • service connections

Getting Started

Installation

git clone https://github.com/AhmetCavus/Minio.git

or

git clone git@github.com:AhmetCavus/Minio.git

cd .\Minio

or

cd Minio

npm i

Configuration

You have to provide an env file '.env' in your project root folder. For securing the api and the socket connection, minio uses the JWT approach. To get more detail about JWT, you can dive into this link https://jwt.io/introduction. This file should contain following keys:

DB_URI=mongodb://user:pass@host:port/collection?authSource=admin
JWT_SECRET=do.not.read.it.is.jwt.secret
VERIFY_SIGNATURE=i.can.open.doors
CLIENT_ID=alone.i.am.useless
SECRET_ID=do.not.read.it.is.client.secret
SSL_KEY=e.g. /etc/domain-name/privkey.pem
SSL_CERT=e.g. /etc/domain-name/fullchain.pem
IS_HTTPS=true/false
KeyDescriptionSample
DB_URIThe url of the db provider. Currently, only the MongoDb engine is supportedmongodb://user:pass@host:port/collection?authSource=admin
JWT_SECRETThe secret id for generating the jwt tokens.do.not.read.it.is.jwt.secret
VERIFY_SIGNATUREThis is applied for provided tokens in the header. If a token cannot be verified with the signature, than it's invalid. Can be any kind of a string valuei.can.open.doors
CLIENT_IDThe id that a client had to use in the header in order to be granted for requests. Must be provided in combination with the secret idalone.i.am.useless
SECRET_IDThe secret that a client had to use in the header in order to be granted for requests. Must be provided in combination with the client iddo.not.read.it.is.client.secret
SSL_KEYIf using HTTPS, than the path of the SSL_KEY had to be specified/etc/domain-name/privkey.pem
SSL_CERTIf using HTTPS, than the path of the SSL_CERT had to be specified/etc/domain-name/fullchain.pem
IS_HTTPSIf enabled, activates https per default. It's recommended to enable this flagtrue or false

Be aware of commiting this file in your repo!!!

Usage

const Minio = require("minio-cms")

const minio = new Minio.App()

minio.start().then(() => {
console.log("Minio is up and running")
})

minio.setting((app, express) => {
app.get("/", (req, res) => {
res.sendFile(\_\_dirname + "/public/index.html")
})
app.use("/todo", require("./routes/todo.route"))
})

For more information check the unit test project folder.

Options

In order to configurate the server and ports, you can specify following values on startup:

minio.start(options)
KeyDescriptionDefault
portSpecify the port8080
modelDirThe path of the models, that should be registered in the dbmodels
enableWebsocketWhether to enable the websocket support or notfalse

Accessing to collections

In order to access the collection provided in the models, you can simply call the code below

const device = minio.collection("device")
// device.model is the mongoose schema

After that, minio provides you convenient methods to notify observers

FunctionDescription
sendBroadcast(message, channelName)Send a broadcast to all oberservers registererd to the given channel name
notifyAddItemCollection(schema, item)Notify all oberservers listening to changes for the given schema and provide the new created item
notifyRemoveItem(schema, item)Notify all oberservers listening to changes for the given schema and provide the removed item
notifyUpdateCollection(schema, items)Notify all oberservers listening to changes for the given schema and provide the items of the changed collection
notifyUpdateCollectionItem(schema, item)Notify all oberservers listening to changes for the given schema and provide the updated item of the collection

For every model schema in your models path, a collection will be created in the database. In addition, it will be supplied with bi-directional communication through sockets. You can get further detail in the API calls section.

Socket events

The table below lists all necessary events that are subscribable for getting or sending notifications.

KeyParameter / OptionsResponseDescription
COMMAND_REQUEST_COLLECTION{ schema: "required - String", condition: { whereKey: "String", whereValue: "String" } }Request a collection that is placed in one of the models folder
EVENT_RECEIVE_COLLECTION[]An array of the requested models
COMMAND_SEND_BROADCAST{ from: "String", to: "String", message: "String" }Sends a broadcast to all members of the specified namespace
EVENT_RECEIVE_BROADCAST{ from: "String", to: "String", message: "String" }Subscribes for incoming broadcasts
COMMAND_SEND_PRIVATE_MESSAGE{ from: "String", to: "String", message: "String" }Sends a private message to the member of the specified namespace
EVENT_RECEIVE_PRIVATE_MESSAGE{ from: "String", to: "String", message: "String" }Subscribes for incoming private messages
COMMAND_COLLECTION_ADD_ITEMThe item to addNotifies all members of the namespace that a new item was added to the collection
EVENT_COLLECTION_ADD_ITEMThe added itemSubscribes for incoming events about recently added items
COMMAND_COLLECTION_REMOVE_ITEMThe item to removeNotifies all members of the namespace that a new item was removed from the collection
EVENT_COLLECTION_REMOVE_ITEMThe removed itemSubscribes for incoming events about recently removed items
COMMAND_COLLECTION_UPDATE_ITEMThe item to updateNotifies all members of the namespace that a new item was updated in the collection
EVENT_COLLECTION_UPDATE_ITEMThe updated itemSubscribes for incoming events about recently updated items

You can also register more events regarding those from Socket.IO by invoking the method

minio.subscribeOn(event, channel, callback)
event = The name of the event as String
channel = The channel name as String
callback = The callback for retrieving data if exists

API calls

The OpenAPI Spec of Minio is provided here Minio.Spec

Creating models

For instructions of creating models, you can check the profile model

In order to create nested list, check following sample file: TodoModel

Starting the application

npm start

Playground

You can enter the playground by calling localhost:[Port] in your browser.

Tests

npm test

Requirements

Node:

  • NodeJS >= 10.16 <=14
  • NPM >= 6.x

Database:

  • MongoDB >= 3.6

We recommend always using the latest version of minio to start your new projects.

Clients

Features

  • Auth service
  • Token service
  • Auto db connection
  • Model service
  • Web socket support

License

See the LICENSE file for licensing information.

0.12.1

3 years ago

0.12.2

2 years ago

0.12.0

3 years ago

0.10.0

3 years ago

0.11.0

3 years ago

0.10.1

3 years ago

0.9.0

3 years ago

0.9.1

3 years ago

0.8.0

3 years ago

0.7.0

3 years ago

0.6.2

3 years ago

0.6.1

3 years ago

0.6.0

3 years ago

0.5.0

3 years ago

0.4.1

3 years ago

0.4.0

3 years ago

0.3.1

3 years ago

0.3.0

3 years ago

0.2.3

3 years ago

0.2.4

3 years ago

0.2.2

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.1.0

3 years ago