New:Microsoft Teams Notifications Are Now Available in Socket.Learn more →
Get Started

@galaxy-stack/orbit-config

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@galaxy-stack/orbit-config

Configuration module for Orbit framework

latest
Source
npmnpm
Version
0.1.10
Version published
Maintainers
1
Created
Source

@galaxy-stack/orbit-config

npm version docs

Part of the Orbit framework — a NestJS-style backend framework for Bun.

Installation

bun add @galaxy-stack/orbit-config

@galaxy-stack/orbit-config

Mô tả

Module quản lý cấu hình cho Orbit với hỗ trợ environment variables và Zod validation.

Tính năng chính

1. ConfigService

import { ConfigService } from '@galaxy-stack/orbit-config';

class MyService {
  constructor(private config: ConfigService) {}

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

  getPort() {
    return this.config.get<number>('PORT', 3000);  // Với default value
  }
}

2. Zod Validation

import { z } from 'zod';
import { ConfigModule } from '@galaxy-stack/orbit-config';

const configSchema = z.object({
  PORT: z.coerce.number().default(3000),
  DATABASE_URL: z.string().url(),
  JWT_SECRET: z.string().min(32),
  NODE_ENV: z.enum(['development', 'production', 'test']),
});

@Module({
  imports: [
    ConfigModule.forRoot({
      schema: configSchema,
      envFile: '.env',
    }),
  ],
})
class AppModule {}

3. Namespace Configuration

import { registerAs } from '@galaxy-stack/orbit-config';

// database.config.ts
export default registerAs('database', () => ({
  host: process.env.DB_HOST,
  port: parseInt(process.env.DB_PORT || '5432'),
  name: process.env.DB_NAME,
}));

// Sử dụng
const dbConfig = this.config.get('database');
console.log(dbConfig.host);

Cấu hình Module

Basic

ConfigModule.forRoot({
  envFile: '.env',
  isGlobal: true,
})

With Validation

ConfigModule.forRoot({
  schema: z.object({
    PORT: z.coerce.number(),
    API_KEY: z.string(),
  }),
  envFile: '.env',
})

Async

ConfigModule.forRootAsync({
  useFactory: async () => ({
    envFile: '.env',
    schema: mySchema,
  }),
})

Environment Files

  • .env - Default
  • .env.local - Local overrides
  • .env.development - Development
  • .env.production - Production
  • .env.test - Testing

Config Methods

interface ConfigService {
  get<T>(key: string): T | undefined;
  get<T>(key: string, defaultValue: T): T;
  getOrThrow<T>(key: string): T;
  has(key: string): boolean;
}

Typed Config

interface DatabaseConfig {
  host: string;
  port: number;
  name: string;
}

const dbConfig = config.get<DatabaseConfig>('database');

FAQs

Package last updated on 26 Sep 2026

Related posts