npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@wbg-mde/server

v1.0.5

Published

MDE communication channel with Socket IO and express.

Downloads

2

Readme

Metadata Editor Server Module

Server module created to manage the bi-directional async requests in the MDE application. This module will be acted as a middle layer to communicate to the repository and r-factory requests.

SocketIO module

This module makes the application bi-directional communication between web clients and servers, Socket IO has two parts: Server side code and client-side code. This package contains the server side codes of MDE application.

Working methodology

The starting point of the application is the server.ts file, this is mentioned in the package.json. This file contains a method called start(), this method will be created an express server instance on a provided PORT. This method will be called from the main application under "electron.server" module. PORT and other related parameters will be provided as options from the main application.

To start server

press F5 to start server

Main socket module

This is the starting point to start the socket io server. Once the server is started it will create an instance of the "MainSocket" class and calls the init() method. This method will be created the server side socket instance and start the connection.

public init(http: any) {   
        const io = require('socket.io')(http);

        // #. Track connections
        io.on('connection', (socket) => {

            // #. Assign active socket
            this.socket = socket;

            // #. Track disconnect
            this.socket.on('disconnect', () => {
                console.log('disconnected');
            });

            this.initAll();
        });
    }
"initAll()" - method

Split the requests as seperate classes for easy handling. This method will create an instance of each classes after the socket connection established.

Example: Create a class to get the request for resequencing the variables

export class ResequenceSocket {
    private socket: any;
    constructor(activeSocket: any) {
        this.socket = activeSocket;
    }

    /*
    * Init resequence - Request will recieved here
    ************************************************/
    public init() {
        this.socket.on('resequence-req', (params: string) => {
            this.resequence(JSON.parse(params));
        });
    }

    private resequence(params: any) {
        rfactory.resequence.resequence(
            params.variables,
            params.filePath,
            params.projectId,
            params.rPath,
            params.language, (response: any) => {
            	//#. Send responce to client - side
                this.socket.emit('resequence-res', { response, projectId: params.projectId, fileId: params.fileId })
            }
        );
    }
}

this class must be registered in the "ModuleSocket" class. ModuleSocket class will be crate the instance of the resequence class and start the socket listening by using 'resequence-req' key.

import { ResequenceSocket } from './modules';
export class ModuleSocket {
    constructor() {
    }

    public initAll(socket: any) {
        // #. Start resequence
        let resq = new ResequenceSocket(socket);
        resq.init();
    }
}

Once the socket established the connection, the "initAll" method from ModuleSocket will be called.

Use emit() method to send response to the client-side. In client Socket IO application expect the response key method to recieve the response.

Environment

  • Node 10.15.3
  • Express 4.16.4
  • socket.io 2.2.0
  • typescript 3.3.4

Contributors

License

MIT