propagande
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

Propagande

Let your front-ends know your message

Propagande is a light library to make server-to-client call, with authentification management

Client-side route

  • Make an express-like route in your browser javascript

Client (Browser):

propagandeApp.addRoute("hello", (params) => {
    console.log(params);
})
  • Then in your nodejs express app, you can call the route of every client connected at once

Server (Node):

await propagandeApp.callRoute('hello', "hello everyone !"),

User Creation and login:

  • Create an user from the server-side

Server (Node):

await propagandeApp.createUser({name: 'roulio',password: 'chien'})
  • you can now login from the client, a cookie session is created and the client doesn't have to reconnect after refreshing the browser.

Client (Browser) :

await propagandeApp.login({name: 'roulio',password: 'chien'})
  • To end a session you can use logout
await propagandeApp.logout()

Call a particular user route from server:

  • Once users are created, the server can call the route of only specified user

Server (Node):

await propagandApp.callRouteUser('roulio', 'hello', "hey, damn you in particular !"),

Front (Browser):

  • The browser code is the same as above
await propagandeApp.login({name: 'roulio',password: 'chien'})
propagandeApp.addRoute("hello", (params) => {
    console.log(params);
})

Groups Management

  • You can also create groups, then assign users to it, then call entire group at once

Server (Node):

await propagandeApp.createGroup('paidUsers')
await propagandeApp.addUsersToGroup(["roulio", "raoul", "cindy"], 'paidUsers')
await propagandeApp.callRouteGroup('paidUsers', 'hello', "hello to all the paid-users")

Setup Propagande

In your NodeJS Express application

$> npm install --save propagande
const { propagandeServer } = require("propagande")
const express = require("express")
 
//...
 
// your express app
const app = express();
app.listen(4000)
 
const propagandeApp = await propagandeServer({
    appName: "fougere", //Give your propagandeApp a name
    // You must create an admin with all right privileges
    admin: { 
        name: "admin",
        password: "admin"
    },
    app, //give your express app
    expressPort: 4000 //give the port of your express app
})
 

Use Propagande Client in your browser

<script src="propagande-min.js"></script>
const propagandeApp = await propagandeClient({
    appName: "fougere", //name of your propagande app
    url: 'http://localhost:4000' // url and port of your express application
})

Readme

Keywords

none

Package Sidebar

Install

npm i propagande

Weekly Downloads

0

Version

1.1.0

License

ISC

Unpacked Size

220 kB

Total Files

34

Last publish

Collaborators

  • dezmou