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 🙏

© 2025 – Pkg Stats / Ryan Hefner

soajs.core.modules

v5.2.17

Published

SOAJS core modules package

Readme

soajs.core.modules

Build Status Coverage Status Known Vulnerabilities npm version

Core modules package for the SOAJS framework, providing essential utilities for logging, database connectivity, email, security, provisioning, and validation.

Table of Contents

Overview

The soajs.core.modules package provides a collection of essential modules used throughout the SOAJS (Service Oriented Architecture JavaScript) framework. These modules handle common tasks such as database operations, email delivery, security, provisioning, and validation.

Installation

npm install soajs.core.modules

Available Modules

The package exports the following modules:

| Module | Description | |--------|-------------| | core | Core utilities including logging, error handling, security, validation, and key management | | mongo | MongoDB database connection and operations | | mongoStore | MongoDB-backed session store for Express | | mail | Email delivery service | | provision | Provisioning utilities for SOAJS services | | hasher | Password hashing utilities | | authorization | Authorization token generation |

Usage

Core Module

The core module provides essential utilities including logging, error handling, security, validation, and metadata management.

const soajsModules = require('soajs.core.modules');

// Get a logger instance
const logger = soajsModules.core.getLogger('myService', { level: 'info' });
logger.info('Service started');

// Error handling
const errorHandler = soajsModules.core.error;

// Key management
const keyManager = soajsModules.core.key;

// Validator
const validator = soajsModules.core.validator;
const isValid = validator.validate(data, schema);

// Get host IP address
soajsModules.core.getHostIp((result) => {
    if (result.result) {
        console.log('Host IP:', result.ip);
    }
});

// Security features
const security = soajsModules.core.security;

MongoDB Module

Provides MongoDB database connectivity and operations for SOAJS services.

const mongo = soajsModules.mongo;

// Initialize MongoDB connection
mongo.init(config, (err) => {
    if (err) {
        console.error('Failed to connect to MongoDB:', err);
        return;
    }

    // Perform database operations
    mongo.find('collectionName', { query: {} }, (err, records) => {
        if (err) {
            console.error('Query failed:', err);
            return;
        }
        console.log('Records:', records);
    });
});

MongoDB Store Module

MongoDB-backed session store for Express applications.

const mongoStore = soajsModules.mongoStore;
const session = require('express-session');

app.use(session({
    store: mongoStore.create({
        mongooseConnection: connection,
        ttl: 14 * 24 * 60 * 60 // 14 days
    }),
    secret: 'your-secret-key',
    resave: false,
    saveUninitialized: false
}));

Mail Module

Email delivery service supporting various transport methods.

const mail = soajsModules.mail;

// Configure mail service
mail.init(mailConfig);

// Send email
mail.send({
    from: '[email protected]',
    to: '[email protected]',
    subject: 'Welcome to SOAJS',
    html: '<h1>Welcome!</h1><p>Thank you for joining.</p>'
}, (err, info) => {
    if (err) {
        console.error('Failed to send email:', err);
        return;
    }
    console.log('Email sent:', info.messageId);
});

Provision Module

Handles provisioning configuration and management for SOAJS services.

const provision = soajsModules.provision;

// Initialize provisioning
provision.init(config, (err) => {
    if (err) {
        console.error('Provisioning failed:', err);
        return;
    }

    // Get provisioning data
    const tenantData = provision.getTenant();
    const envData = provision.getEnvironment();
});

Hasher Utility

Secure password hashing using bcrypt.

const hasher = soajsModules.hasher;

// Hash a password
hasher.hash('myPassword', (err, hashedPassword) => {
    if (err) {
        console.error('Hashing failed:', err);
        return;
    }
    console.log('Hashed password:', hashedPassword);
});

// Compare password with hash
hasher.compare('myPassword', hashedPassword, (err, isMatch) => {
    if (err) {
        console.error('Comparison failed:', err);
        return;
    }
    console.log('Password matches:', isMatch);
});

Authorization Utility

Generate authorization tokens for SOAJS services.

const authorization = soajsModules.authorization;

// Generate authorization token
const token = authorization.generate({
    id: 'user123',
    tenant: 'tenant1',
    expires: Date.now() + (60 * 60 * 1000) // 1 hour
});

console.log('Authorization token:', token);

Testing

Run the test suite:

npm test

The package uses Grunt with Mocha for testing and Istanbul for coverage reporting.

Documentation

For detailed API documentation and usage guides, visit the SOAJS Wiki.

License

Copyright SOAJS All Rights Reserved.

Use of this source code is governed by an Apache license that can be found in the LICENSE file at the root of this repository.