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

modulino

v1.0.18

Published

Simple NodeJS Application Server

Downloads

1

Readme

modulino

Simple NodeJS Application Server. It loads and reloads services from filesystem automatically without any server or NodeJS restarts. Supports EJS and Pug templating engines out of the box.

Installation

npm i modulino

Example

Create file example.js

#!/usr/bin/env node

const {forExpress, addUser} = require("modulino");
const express = require('express');
const bodyParser = require('body-parser');
const expressWs = require('express-ws');

const app = express();
expressWs(app);

// support json encoded bodies
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: true}));

const port = 8000;

addUser({
  "username":"test",
  "name":"User",
  "emails":["[email protected]"],
  "sshKeys":[{
    "name":"test",
    "publicKey":
      "-----BEGIN RSA PUBLIC KEY-----\n"+
      "MIIBCgKCAQEAq1cg8Py7KNJiTSrQ3busKqjTLJruNDrKiBTXQuYe7DUsNNZHd6F2\n"+
      "8Hzi1Eb5QGiN/KwMNfdoNfB53xBIUztxv5zwYmpnwv8JwBMPMdnOoAPrjHCEiq9l\n"+
      "d6dNtkuJfVp3roqmIyc5KntKEda/EIn4GCLsB/wGBcvaxGDroyJIyGYmJ7rJwC/e\n"+
      "pf/wJjXBro1sShAPh4//gURH42rcR+rUTwnzdApJJBeCbccoDLejKa/OB8QRlLeD\n"+
      "+3BTysLDeQhapVlUXi+r4YJHoMPGsnGvimVQAtgMkHvp+mzE7G7NzvNjlqkdqej+\n"+
      "bli1xCcpo0UCaBCnmxv17kRPUakfb7jJTwIDAQAB\n"+
      "-----END RSA PUBLIC KEY-----\n"
    }]
  }
);

forExpress(app, {
    consoleLogger: true,
    contexts: [
        {path: 'web', headers: {host: `localhost:${port}`}}
    ],
    administrationApi: '/administrationApi',
}).then(() => app.listen(port, () =>
    console.log(`server started on port http://localhost:${port}`)
));

Run this commands

npm install --save modulino body-parser express express-ws

node example.js

Create file web/test.mod.js

const {onRequest} = require('api');

onRequest((req, res) => {
    const {body} = req;
    res.type('js');
    res.send({message:"Hello world!", requstData: body});
});

Open the test service.

You can edit file web/test.mod.js without any server restarts and check that your service is changing results.

Create file web/index.html

<!DOCTYPE html>
<head>
    <title>Title</title>
</head>
<body>
 Hello
</body>
</html>

Open the main page.

Notice: This module has 'nodemailer' NPM dependency.

Develop remotely

Create file client.js in any empty directory

#!/usr/bin/env node

const {connect} = require("modulino");

const url = "ws://localhost:8000/administrationApi";

const username = "test";
const email = "[email protected]";
const privateKey = "-----BEGIN RSA PRIVATE KEY-----\n"+
  "MIIEpAIBAAKCAQEAq1cg8Py7KNJiTSrQ3busKqjTLJruNDrKiBTXQuYe7DUsNNZH\n"+
  "d6F28Hzi1Eb5QGiN/KwMNfdoNfB53xBIUztxv5zwYmpnwv8JwBMPMdnOoAPrjHCE\n"+
  "iq9ld6dNtkuJfVp3roqmIyc5KntKEda/EIn4GCLsB/wGBcvaxGDroyJIyGYmJ7rJ\n"+
  "wC/epf/wJjXBro1sShAPh4//gURH42rcR+rUTwnzdApJJBeC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HhvQTui\n"+
  "kmmuB5NmjzgUXuXUxRMlGQKBgQCLX0Tj8cp/J1K/EY0ZHRX0SWPbwu8zxD0iNViR\n"+
  "UQlNPY1ZgXfBSjiyVoce7AHsAMvdM+bEVLBxSEvc9effI6sWjjjBKhrkRPFXIlj1\n"+
  "2dkID35E1WtGDapbv5cB5fs9mk9yVsfrMSgYYFgvmJulOr6qUcrKxddNfL4HEkEr\n"+
  "EZvHgQKBgQCAMXLeJT7tlYHSsCPi0alFY2y/AGcLkQ0qjpLae24GJJYKPIL1wmgm\n"+
  "hrxTi0eW4ulAPFzDIZBqjqY/g9c+Fs7eXwBuRcH5e2xKKmFP7TrwytzPCQ/k0Drh\n"+
  "z/B+tiRFMsX/uX1ckQMx+FavslkVXeI1sR3fenptYoyfnoZL1mltsQ==\n"+
  "-----END RSA PRIVATE KEY-----\n";

connect({url, privateKey, username, email});

Run this commands to be able to remotely

npm install modulino ws

node client.js

It will download all files from server and upload them after any change on filesystem. It also shows logs from server.

Get public key in PEM format from your ssh RSA key pair:

ssh-keygen -f ~/.ssh/id_rsa -e -m pem

Generating your own keys using NodeJS (newest version required):

const { generateKeyPair } = require('crypto');

generateKeyPair('rsa', {
    modulusLength: 2048,
    publicKeyEncoding: {type: 'pkcs1', format: 'pem'},
    privateKeyEncoding: {type: 'pkcs1', format: 'pem'}
}, (err, publicKey, privateKey) => {
    if (!err) {
        console.log(
            'RSA key generated, you can add user on server: \n\n'+
            'const {addUser} = require("modulino");\n\n'+
            'addUser('+JSON.stringify({
                username: "test",
                name: "User",
                emails: ["[email protected]"],
                sshKeys: [{name: "test", publicKey}]
            })+');\n\n\n' +
            'Also you can to connect to your server using WS client::\n\n'+
            'const {connect} = require("modulino");\n\n' +
            'const username = "test";\n' +
            'const email = "[email protected]";\n' +
            'const url = "ws://localhost:8000/administrationApi";\n' +
            'const privateKey = "'+privateKey.split('\n').join('\\n"+\n  "')+'";\n\n'+
            'connect({url, privateKey, username, email});'
        );
    } else {
        console.error('Can not generate RSA keys:', err);
    }
});

License

MIT License