Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ahmetcavus/minio
A minimal sandbox providing a handy way to start with a backend application.
https://github.com/ahmetcavus/minio
cms express headless-cms javascript leightweight mongodb nodejs socket-io
Last synced: about 1 month ago
JSON representation
A minimal sandbox providing a handy way to start with a backend application.
- Host: GitHub
- URL: https://github.com/ahmetcavus/minio
- Owner: AhmetCavus
- License: mit
- Created: 2020-05-11T16:54:01.000Z (over 4 years ago)
- Default Branch: develop
- Last Pushed: 2023-01-07T11:04:06.000Z (almost 2 years ago)
- Last Synced: 2024-10-14T20:21:36.088Z (about 1 month ago)
- Topics: cms, express, headless-cms, javascript, leightweight, mongodb, nodejs, socket-io
- Language: JavaScript
- Homepage:
- Size: 6.46 MB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Minio
![Build Status](https://dev.azure.com/cinary/Minio/_apis/build/status/AhmetCavus.Minio?branchName=develop)
![Azure DevOps coverage](https://img.shields.io/azure-devops/coverage/cinary/minio/8)
![Azure DevOps tests](https://img.shields.io/azure-devops/tests/cinary/minio/8)
![npm](https://img.shields.io/npm/v/minio-cms)Minio is an easy to use minimalistic sandbox project providing
- auth
- token
- model
- securityservices 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 [email protected]: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
```| Key | Description | Sample |
| ----------- | :------------------------------------------------------------------------- | :---------------------------------------- |
| DB_URI | The url of the db provider. Currently, only the MongoDb engine is supported | mongodb://user:pass@host:port/collection?authSource=admin |
| JWT_SECRET | The secret id for generating the jwt tokens. | do.not.read.it.is.jwt.secret |
| VERIFY_SIGNATURE | This 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 value | i.can.open.doors |
| CLIENT_ID | The 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 id | alone.i.am.useless |
| SECRET_ID | The 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 id | do.not.read.it.is.client.secret |
| SSL_KEY | If using HTTPS, than the path of the SSL_KEY had to be specified | /etc/domain-name/privkey.pem |
| SSL_CERT | If using HTTPS, than the path of the SSL_CERT had to be specified | /etc/domain-name/fullchain.pem |
| IS_HTTPS | If enabled, activates https per default. It's recommended to enable this flag | true or false |Be aware of commiting this file in your repo!!!
### Usage
```nodejs
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:
```nodejs
minio.start(options)
```| Key | Description | Default |
| ----------- | :------------------------------------------------------------------------- | :----------------------------------------- |
| port | Specify the port | 8080 |
| modelDir | The path of the models, that should be registered in the db | models |
| enableWebsocket | Whether to enable the websocket support or not | false |### Accessing to collections
In order to access the collection provided in the models, you can simply call the code below
```nodejs
const device = minio.collection("device")
// device.model is the mongoose schema
```
After that, minio provides you convenient methods to notify observers| Function | Description |
| ----------- | :------------------------------------------------------------------------- |
| 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.
| Key | Parameter / Options | Response | Description |
| :- | :- | :- | :- |
| 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_ITEM | The item to add | | Notifies all members of the namespace that a new item was added to the collection |
| EVENT_COLLECTION_ADD_ITEM | | The added item | Subscribes for incoming events about recently added items |
| COMMAND_COLLECTION_REMOVE_ITEM | The item to remove | | Notifies all members of the namespace that a new item was removed from the collection |
| EVENT_COLLECTION_REMOVE_ITEM | | The removed item | Subscribes for incoming events about recently removed items |
| COMMAND_COLLECTION_UPDATE_ITEM | The item to update | | Notifies all members of the namespace that a new item was updated in the collection |
| EVENT_COLLECTION_UPDATE_ITEM | | The updated item | Subscribes for incoming events about recently updated items |You can also register more events regarding those from Socket.IO by invoking the method
```nodejs
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](https://github.com/AhmetCavus/Minio.Spec)
### Creating models
For instructions of creating models, you can check the [profile model](./src/core/models/profile.model.js)
In order to create nested list, check following sample file: [TodoModel](./app/models/todo.js)
### 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
- Dart / Flutter [Minio.ClientDart](https://github.com/AhmetCavus/Minio.ClientDart)
- Javascript *In progress*
- .Net C# *In progress*## Features
- **Auth service**
- **Token service**
- **Auto db connection**
- **Model service**
- **Web socket support**## License
See the [LICENSE](./LICENSE) file for licensing information.