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

@zanobijs/common

v1.0.2

Published

Zanobi - modern, small, powerful node.js lambda framework (@common)

Downloads

229

Readme

npm coverage test nodejs typescrit licence Doc

It is a mini-framework for Node.js that allows you to build server-side microservices in an efficient and scalable way. It is designed to be small and efficient, but powerful enough for enterprise applications. ZanobiJS is written in TypeScript and JavaScript, giving you the flexibility to choose the language you prefer.

Features

  • Small and efficient.
  • Written in TypeScript/JavaScript.
  • Ideal for building server-side microservices.
  • Optimized scalability and performance.

Getting started

If you want to consult the guide and learn about the project, visit zanobijs.vercel.app

Installation

Install my-project with npm

  npm install @zanobijs/common @zanobijs/core

Directories

├── ...
├── example                   # Feature example
│   ├── example.controller.ts # Controller
|   ├── example.service.ts    # Service
├── app.module.ts             # Main Module
├── index.ts                  # Handler or bootstrap
└── ...

Usage/Examples

example.service.ts

import { Inject, Injectable } from "@zanobijs/common";

@Injectable()
export class ServiceExample {
  constructor(
    @Inject("API_CLIENT") private apiClient: string,
    @Inject("API_KEY") private apiKey: string
  ) {}
  getHello() {
    return "Hello ServiceExample";
  }
  getApiClient(){
    return this.apiClient
  }
  getApiKey(){
    return this.apiKey
  }
}

example.controller.ts

import { Controller, Inject } from "@zanobijs/common";
import { ServiceExample } from "./example.service";

@Controller()
export class ControllerExample {
  constructor(
    private sExample: ServiceExample,
    @Inject("API_URL") private apiUrl: string
  ) {
    this.apiUrl = apiUrl;
  }

  getApiUrl() {
    return this.apiUrl;
  }
  getHelloService() {
    return this.sExample.getHello();
  }
  getClienteService() {
    return this.sExample.getApiClient();
  }
  getKeyService() {
    return this.sExample.getApiKey();
  }
}

AppModule.ts

import { Module } from "@zanobijs/common";
import { ControllerExample } from "./example/example.controller";
import { ServiceExample } from "./example/example.service";

@Module({
  imports: [],
  controllers: [ControllerExample],
  services: [
    ServiceExample,
    {
      provider: "API_URL",
      useValue: "https://url.com",
    },
    {
      provider: "API_KEY",
      useValue: "myKey12345API",
    },
    {
      provider: "API_CLIENT",
      useValue: "thisClientAPI",
    },
  ],
  exports: [],
})
export class AppModule {}

Index.ts

import { Factory } from "@zanobijs/core";
import { AppModule } from "./app.module";
import { ControllerExample } from "./example/example.controller";


const bootstrap = () => {
  const factory = new Factory(AppModule);
  const app = factory.create();
  const controllerExample = app.get<ControllerExample>(
    "controllerExample"
  );
  console.log(controllerExample.getHelloService());
  console.log(controllerExample.getApiUrl());
  console.log(controllerExample.getClienteService());
  console.log(controllerExample.getKeyService());
}
bootstrap();
// Hello ServiceExample
// https://url.com
// thisClientAPI
// myKey12345API

[!Note] It can also be used in AWS lambda, see how to do it in the guide

Use Logger

  • Import logger service of @zanobij/common/utils.
  • Define whether the record is visible. [Default is false]
  • Get the service.
  • Use the different events (success, info, warn, error, debug).
// Index.ts - This is important for the operation
const factory = new Factory(AppModule, {
  activeLoggerUser: true
});

// use en services controllers, etc

import { LoggerUser } from "@zanobijs/common/utils";

const logUser = LoggerUser();

logUser.success("Lorem ipsum success");
logUser.info("Lorem ipsum info");
logUser.warn("Lorem ipsum warn");
logUser.error("Lorem ipsum error");
logUser.debug("Lorem ipsum debug");

// ***** PRINT *****
// [SUCCESS]: Lorem ipsum success     <green print>
// [INFO]: Lorem ipsum info           <blue print>
// [WARN]: Lorem ipsum warn           <yellow print>
// [ERROR]: Lorem ipsum error         <red print>
// [DEBUG]: Lorem ipsum debug         <white print>

Authors

Credits

ZanobiJS is heavily inspired by NestJS and AngularJS.

Additionally, it is used Awilix which is a container for Extremely powerful and effective dependency injection.

Finally, it is an effort that we make and that we hope can help in the construction of projects.

License

Private - Read License