Giter Site home page Giter Site logo

deflexable / mosquito-transport Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 396 KB

MosquitoTransport is a powerful tool that helps persist and synchronize data between your MongoDB database and frontend applications

License: MIT License

JavaScript 100.00%
javascript database firebase self-database selfhosted serverless fully-queried mongodb mongodb-realm

mosquito-transport's Introduction

mosquito-transport

MosquitoTransport is a powerful tool that enables developers to persist and synchronize data between their MongoDB database and frontend applications. It offers a centralized and self-hosted solution for managing server infrastructure and data, along with robust authentication, real-time data updates, scalability, and cross-platform compatibility.

Under the hood, mosquito-transport uses Mongodb to store it data and express, socket.io for making request and jwt for signing authentication token, so make sure you have mongodb installed before using this package.

Key features of mosquito-transport include:

  • Data Persistence and Synchronization ๐Ÿ”:
    • Seamlessly persist and synchronize data between MongoDB and frontend applications, ensuring consistency across all clients.
  • Self-Hosted Server ๐Ÿ’พ:
    • Host your own server infrastructure, giving you full control over data storage, access, and management.
  • User Authentication and Authorization ๐Ÿ”:
    • Easily implement user authentication and authorization using JWT (JSON Web Tokens), providing secure access control to your application's resources.
  • End-to-End Encryption ๐Ÿ”—:
    • Optionally enforce end-to-end encryption by allowing only encrypted data to be transmitted between client and server, ensuring data privacy and security.
  • Real-Time Data Updates ๐Ÿšจ:
    • Enable real-time updates to keep data synchronized across all clients in real-time, providing a seamless user experience.
  • Scalability and Performance ๐Ÿš›:
    • Benefit from auto-scaling and high performance, allowing your application to handle varying workloads with ease.
  • Cross-Platform Compatibility ๐Ÿ“ฑ:
    • Compatible with React Native and web applications, allowing you to build cross-platform solutions with ease.

Installation

npm install mosquito-transport

or using yarn

yarn add mosquito-transport

Usage

import MosquitoTransportServer from "mosquito-transport";
import { MongoClient } from 'mongodb';

// create a mongodb instance
const dbInstance = new MongoClient('mongodb://127.0.0.1:27017', {
    useNewUrlParser: true,
    useUnifiedTopology: true
});

dbInstance.connect().then(() => {
    console.log('connected to mongodb at');
}).catch(e => {
    console.error('failed to connected to mongodb at');
});

// setup your server
const serverApp = new MosquitoTransportServer({
  projectName: 'app_name',
  port: 4534, // defaults to 4291
  signerKey: 'random_90_hash_key_for_signing_jwt_tokens', // must be 90 length
  accessKey: 'this_is_my_private_password', // keep this private if you don't provide databaseRules or storageRules
  mongoInstances: {
      // this is where user info and tokens is stored
      admin: {
          instance: dbInstance,
          defaultName: 'ADMIN_DB_NAME'
      },
      // this will be the default db if no dbName was provided
      default: {
          instance: dbInstance,
          defaultName: 'DEFAULT_DB_NAME'
      }
  },
  databaseRules: ({ auth, collection, value, afterData, beforeData, operation, ...otherProps })=> new Promise((resolve, reject)=> {
    // validate and authorize all incoming request to the database
    if (collection === 'user') {
        if (afterData && auth && auth.uid === value._id) {
            resolve(); // allow read/write
        } else reject('You don`t own this data, stay away'); // reject read/write
    } else if (collection === 'other_paths') {
      // blah, blah, other algorithm ...
    }
  }),
  storageRules: ({...props})=> new Promise(resolve=> {
    // validate and authorize all uploads/downloads
    resolve(true) // handle read/write yourself here
  }),
  googleAuthConfig: {
    clientID: 'your_google_authentication_clientID.apps.googleusercontent.com'
  },
  appleAuthConfig: {
    ...props
  },
  ...otherProps
});

your server is now ready to be deploy on node.js! ๐Ÿš€. Now install any mosquito-transport client sdk and start making requests to the server.

SDKs And Hacks

Additional Documentations

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT


mosquito-transport's People

Contributors

deflexable avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.