🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

@vitra-ai/nestjs-core

Package Overview
Dependencies
Maintainers
5
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

@vitra-ai/nestjs-core

Core utilities for NestJS applications including configuration and database management

latest
Source
npmnpm
Version
0.1.0
Version published
Maintainers
5
Created
Source

@vitra-ai/nestjs-core

Core utilities for NestJS applications including configuration management with Zod validation and Sequelize database integration.

Features

  • 🔧 Type-safe Configuration: Zod-validated environment configuration with TypeScript types
  • 🗄️ Database Integration: Sequelize configuration and utilities
  • 📦 Zero Config: Works out of the box with sensible defaults
  • 🚀 Production Ready: Battle-tested utilities for enterprise applications

Installation

npm install @vitra-ai/nestjs-core
# or
yarn add @vitra-ai/nestjs-core
# or
bun add @vitra-ai/nestjs-core

Peer Dependencies

npm install @nestjs/common @nestjs/core @nestjs/config @nestjs/sequelize zod pg sequelize sequelize-typescript

Usage

Configuration Module

The ZodConfigModule provides type-safe configuration management with Zod validation.

import { Module } from '@nestjs/common';
import { ZodConfigModule } from '@vitra-ai/nestjs-core';
import { z } from 'zod';

// Define your environment schema
const EnvSchema = z.object({
  NODE_ENV: z.enum(['development', 'production', 'test']),
  PORT: z.coerce.number().default(3000),
  DATABASE_URL: z.string(),
});

@Module({
  imports: [
    ZodConfigModule.forRoot(EnvSchema, {
      isGlobal: true,
      envFilePath: ['.env', '.env.local'],
    }),
  ],
})
export class AppModule {}

Typed Config Service

Access your configuration with full type safety:

import { Injectable } from '@nestjs/common';
import { ConfigService } from '@vitra-ai/nestjs-core';
import { z } from 'zod';

const EnvSchema = z.object({
  PORT: z.coerce.number(),
  DATABASE_URL: z.string(),
});

type EnvType = z.infer<typeof EnvSchema>;

@Injectable()
export class AppService {
  constructor(private config: ConfigService<EnvType>) {}

  getPort() {
    return this.config.get('PORT'); // Fully typed!
  }

  getDatabaseUrl() {
    return this.config.get('DATABASE_URL');
  }

  getOptionalValue() {
    return this.config.optional('SOME_OPTIONAL_KEY');
  }

  getWithDefault() {
    return this.config.getOr('TIMEOUT', 5000);
  }
}

Database Integration

Use the SequelizeOptions provider for database configuration:

import { Module } from '@nestjs/common';
import { SequelizeModule } from '@nestjs/sequelize';
import { 
  ZodConfigModule, 
  SequelizeOptions, 
  DATABASE_ENV_CONFIG 
} from '@vitra-ai/nestjs-core';

@Module({
  imports: [
    ZodConfigModule.forRoot(DATABASE_ENV_CONFIG, {
      isGlobal: true,
    }),
    SequelizeModule.forRootAsync({
      useClass: SequelizeOptions,
      imports: [ZodConfigModule.forRoot(DATABASE_ENV_CONFIG)],
    }),
  ],
})
export class AppModule {}

Environment Variables

The DATABASE_ENV_CONFIG expects these environment variables:

DB_DIALECT=postgres
DB_USER=myuser
DB_PASSWORD=mypassword
DB_HOST=localhost
DB_PORT=5432
DB_NAME=mydb
DB_LOGGING_ENABLED=false

API Reference

ZodConfigModule

  • forRoot<T>(schema: ZodObject<T>, options?: ConfigModuleOptions) - Initialize the config module with Zod validation

ConfigService<S>

  • get<K>(key: K): S[K] - Get a required config value (throws if missing)
  • optional<K>(key: K): S[K] | undefined - Get an optional config value
  • getOr<K>(key: K, fallback: S[K]): S[K] - Get a value with a fallback

SequelizeOptions

Database configuration provider implementing SequelizeOptionsFactory.

DATABASE_ENV_CONFIG

Pre-configured Zod schema for database environment variables.

License

MIT

Keywords

nestjs

FAQs

Package last updated on 19 Nov 2025

Did you know?

Socket

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.

Install

Related posts