Skip to content

Welcome to S42- Core

Start building the next generation of backend solutions with s42-core!

What is s42-core?

Introduction

s42-core is a powerful and flexible Node.js library designed to streamline the development of modular and scalable applications. It is particularly well-suited for building microservices and cell-based architectures, enabling developers to create high-performance, maintainable solutions.

Key Features

Microservices and Cell-Based Architectures

s42-core is built with microservices and cell-based architectures in mind. It allows you to create highly modular applications where each microservice or cell can operate independently. This modularity facilitates easier maintenance, updates, and scalability.

Framework Agnostic

One of the standout features of s42-core is its framework-agnostic design. This means you can integrate s42-core with any framework of your choice, such as Express, Nest.js, Fastify, and more. You are not forced to change your existing stack, allowing for an iterative adoption of the library.

High Performance

Applications developed with s42-core benefit from exceptional performance, making it ideal for high-demand environments. The library leverages efficient patterns and practices to ensure your applications run smoothly and responsively.

Simplified Monorepo Management

s42-core makes it easy to create and manage monorepos. By promoting the development of small, reusable software components (atoms), it ensures that code can be easily shared and reused across multiple projects within a single repository.

Listen eventsDomain

import { Shutdown, Cluster, EventsDomain, RedisClient } from 's42-core'
export type UsersCreated = {
email: string
firstName: string
lastName: string
lang: 'en' | 'es' | 'it' | 'fr'
template: string
}
Cluster(
1, // only one instance
async (pid, uuid) => {
console.info('initializing event user.created listener : ', pid, uuid)
const redisInstance = RedisClient.getInstance(process.env.REDIS_URI)
const eventsDomain = EventsDomain.getInstance(redisInstance, uuid)
eventsDomain.listenEvent<UsersCreated>(
`users.created`,
async (payload: UsersCreated) => {
try {
console.info('Email sent successfully:', payload)
eventsDomain.emitEvent('users.created.email.sent', { ok: true })
} catch (error) {
console.error('Error sending email:', error)
}
},
)
Shutdown([eventsDomain.close, redisInstance.close])
},
() => {
console.info('Error trying start servers')
},
)

Use cases

Building Microservices

s42-core simplifies the development of microservices by providing essential utilities for handling HTTP requests, managing dependencies, and interacting with databases. This enables you to quickly set up and deploy scalable services.

Event-Driven Architecture

With the EventsDomain class, s42-core supports event-driven architecture, allowing your microservices and cells to communicate efficiently through domain events. This pattern enhances the decoupling of services and improves system resilience.

Creating Modular Components

The library encourages the creation of small, reusable software components, or atoms, which can be combined to build more complex functionality. This approach improves code maintainability and scalability.

Getting Started

Start building the next generation of backend solutions with s42-core. Whether you are creating a new application or enhancing an existing one, s42-core provides the tools you need to develop modular, high-performance, and maintainable software.


For assistance, you can contact the author via Telegram or email:

Explore the documentation to learn more about how to leverage the power of s42-core in your projects.

Next steps