
Product
Introducing Webhook Events for Alert Changes
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.
server-modules
Advanced tools
Easy configurable server modules (logging, express, api, websocket, mongodb)
This packages provides some easy-to-use utilities to setup a server with node.js.
import { ServerEnvironment } from 'server-modules';
// check /modules/logger/_interface.d.ts for additional options
const Server = new ServerEnvironment(
{
ident: 'Example-Server',
logger: {
console: {
level: 'silly'
},
file: {
path: './logs',
levels: ['info', 'warn', 'error']
}
}
}
);
const logger = Server.logger.spawn('my-module');
logger.info(`Logger created`);
Server
.createExpress({
port: 8080,
init: app => {
/*
* setup app
* this will be applied after
* cookieParser() / bodyParser.json() / compression() / morgan()
* the server will send a 404 status message if no route was found
*/
}
});
import { ApiSegment } from 'server-modules';
export const MyAPISegment = new ApiSegment('api');
MyAPISegment
.addRoute<{txt:string}>('echo/:txt')
.get((req, res) => {
const { params } = req;
res.send(params.txt);
});
Server
.createExpress({
port: 8081,
init: [MyAPISegment]
});
Server
.createExpress({
port: 8082,
init: app => {
MyAPISegment.registerOn(Server.logger, app);
}
});
Server
.createWebsocket(
{
port: 3001,
connection: MyWebsocketConnection
});
import { WebsocketConnection } from 'server-modules';
export class MyWebsocketConnection extends WebsocketConnection {
init() {
/* register event listeners */
this._socket.on('ping', () => {
this._socket.emit('pong');
});
}
}
const Client = Server.connectMongoDb({ auth });
Client.connect(db => {
/* work on database or save reference to db */
});
interface MongoDbConnectionCfg {
port?: number; // default: 27017
host?: string; // default: localhost
auth?: { // default: undefined
database?: string; // default: admin
user: string;
password: string;
};
options?: MongoClientOptions; // default: {}
}
FAQs
Easy configurable server modules (logging, express, api, websocket, mongodb)
The npm package server-modules receives a total of 1 weekly downloads. As such, server-modules popularity was classified as not popular.
We found that server-modules demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.

Security News
ENISA has become a CVE Program Root, giving the EU a central authority for coordinating vulnerability reporting, disclosure, and cross-border response.

Product
Socket now scans OpenVSX extensions, giving teams early detection of risky behaviors, hidden capabilities, and supply chain threats in developer tools.