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")
const app = express();
app.listen(4000)
const propagandeApp = await propagandeServer({
appName: "fougere",
admin: {
name: "admin",
password: "admin"
},
app,
expressPort: 4000
})
Use Propagande Client in your browser
<script src="propagande-min.js"></script>
const propagandeApp = await propagandeClient({
appName: "fougere",
url: 'http://localhost:4000'
})