0.3.3 • Published 4 years ago

benx4-bee-hive v0.3.3

Weekly downloads
63
License
-
Repository
-
Last release
4 years ago

benx4-bee-hive

This module is a very basic framework to create a micro-frontend.

Usage:

To create a page by using this module, you must give out a json to the beehive, as follow:

    const pages = {
        "/home": [
            {
                "mount": "#top",
                "script": "_scripts_main-top.js"
            },
            {
                "mount": "#center",
                "script": "_scripts_main-center.js"
            },
            {
                "mount": "#bottom",
                "script": "_scripts_main-bottom.js"
            }
        ],
        "/detail": [
            {
                "mount": "#top",
                "script": "_scripts_detail-top.js"
            },
            {
                "mount": "#center",
                "script": "_scripts_detail-center.js"
            },
            {
                "mount": "#bottom",
                "script": "_scripts_detail-bottom.js"
            }
        ],
        "/profile": [
            {
                "mount": "#center",
                "script": "_scripts_profile-center.js"
            }
        ]
    }

The json is mainly to describe the page of whose the partial view included.

After the json created. Here is the example:

    const beeHive = BeeHive.createInstance(pages);
    beeHive.init();

    window.addEventListener("load", function () {
        document.querySelector("#btnDetail").onclick = function () {
            beeHive.attach(“_detail”);	/_dynamically attach the page on the mount point.
        }

        document.querySelector("#btnProfile").onclick = function () {
            beeHive.attach(“/profile”);
        }
        document.querySelector("#btnHome").onclick = function () {
            beeHive.attach(“/home”);
        }
    });

and don’t forget if you wanna by using this method to complete the micro-frontend, you must set the nginx etc. server to accept the request, here I provide the nginx.conf which maybe needed.

    worker_processes 1;

    events {
        worker_connections 1024;
    }

    http {
        server {
            server_name localhost;
            listen 8050;

            location / {

                root _xxx_hive-path;
                index index.html;

                try_files $uri $uri/ /index.html; # the index.html is the page you need to set to accept the param or query sting
            }
        }
    }
0.3.2

4 years ago

0.3.3

4 years ago

0.3.1

4 years ago

0.2.10

4 years ago

0.3.0

4 years ago

0.2.16

4 years ago

0.2.15

4 years ago

0.2.14

4 years ago

0.2.13

4 years ago

0.2.12

4 years ago

0.2.11

4 years ago

0.2.9

4 years ago

0.2.7

4 years ago

0.2.6

4 years ago

0.2.8

4 years ago

0.2.5

4 years ago

0.2.3

4 years ago

0.2.4

4 years ago

0.2.1

4 years ago

0.2.0

4 years ago

0.1.0

4 years ago