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

@sorodriguez/nest-cloud-config-server

v1.0.2

Published

Centralized configuration server for NestJS applications, inspired by Spring Cloud Config Server

Readme

Nest Cloud Config Server

English | Español

Centralized configuration server for NestJS applications, inspired by Spring Cloud Config Server. Manage configurations for multiple applications from Git repositories (GitHub, GitLab, Azure DevOps).

🚀 Features

  • ✅ Multiple Git repository support
  • ✅ Compatible with GitHub, GitLab, and Azure DevOps
  • ✅ Multiple file formats: JSON, YAML, XML, Properties
  • ✅ Automatic repository synchronization
  • ✅ Flat format with dot notation for all configurations
  • ✅ Profile management (dev, prod, test, etc.)
  • ✅ Simple and clear REST API
  • ✅ NestJS global module

📦 Installation

npm install @sorodriguez/nest-cloud-config-server

🔧 Basic Setup

1. Import the module in your application

import { Module } from "@nestjs/common";
import {
  ConfigServerModule,
  RepositoryType,
} from "@sorodriguez/nest-cloud-config-server";

@Module({
  imports: [
    ConfigServerModule.forRoot({
      baseRepoPath: "../repos", // Directory where repositories will be cloned
      repositories: [
        {
          name: RepositoryType.GITHUB,
          host: "github.com",
          protocol: "https",
          organization: "your-organization",
          repository: "config-repo",
          branch: "main",
          auth: {
            username: "your-username",
            token: "your-token", // Personal Access Token
          },
        },
      ],
    }),
  ],
})
export class AppModule {}

2. Configuration with multiple repositories

ConfigServerModule.forRoot({
  baseRepoPath: "../repos",
  repositories: [
    {
      name: RepositoryType.GITHUB,
      host: "github.com",
      protocol: "https",
      organization: "my-org",
      repository: "config-prod",
      branch: "main",
      auth: {
        username: "username",
        token: "ghp_xxxxx",
      },
    },
    {
      name: RepositoryType.GITLAB,
      host: "gitlab.com",
      protocol: "https",
      organization: "my-group",
      repository: "config-dev",
      branch: "develop",
      auth: {
        username: "username",
        token: "glpat-xxxxx",
      },
    },
    {
      name: RepositoryType.AZURE,
      host: "dev.azure.com",
      protocol: "https",
      organization: "my-company",
      repository: "config-test",
      branch: "test",
      auth: {
        username: "username",
        token: "xxxxx",
      },
    },
  ],
});

📂 File Structure in Repository

Organize your configuration files with the following pattern:

config-repo/
├── my-app-dev.json
├── my-app-prod.yaml
├── my-app-test.properties
├── another-app-dev.xml
└── another-app-prod.json

Pattern: {application}-{profile}.{extension}

🌐 API Endpoints

1. Get Configuration

GET /?repo={repo}&application={app}&profile={profile}

Get the configuration for a specific application in flat format.

Parameters:

  • repo: Repository name
  • application: Application name
  • profile: Configuration profile (dev, prod, test, etc.)

Example:

curl "http://localhost:3000/?repo=config-repo&application=my-app&profile=dev"

Response (flat format):

{
  "server.port": 8080,
  "server.host": "localhost",
  "database.url": "jdbc:mysql://localhost:3306/db",
  "database.username": "root",
  "database.pool.max": 10,
  "feature.flags.enabled": true
}

2. Synchronize Repositories

POST /sync

Synchronize all repositories forcefully (hard reset + pull).

Example:

curl -X POST http://localhost:3000/sync

Response:

{
  "message": "Repositories synchronized successfully"
}

3. List Directories and Files

GET /directories

List all cloned repositories and their configuration files.

Example:

curl http://localhost:3000/directories

Response:

[
  {
    "name": "config-repo",
    "files": [
      "my-app-dev.json",
      "my-app-prod.yaml",
      "another-app-dev.properties"
    ]
  }
]

📝 Supported Formats

JSON

{
  "server": {
    "port": 8080,
    "host": "localhost"
  }
}

YAML

server:
  port: 8080
  host: localhost

Properties

server.port=8080
server.host=localhost

XML

<?xml version="1.0" encoding="UTF-8"?>
<config>
  <server>
    <port>8080</port>
    <host>localhost</host>
  </server>
</config>

All configurations are returned in flat format:

{
  "server.port": 8080,
  "server.host": "localhost"
}

🔐 Git Authentication

GitHub

Generate a Personal Access Token (PAT):

  1. Go to Settings → Developer settings → Personal access tokens → Tokens (classic)
  2. Generate new token with repo permission
  3. Use the token in configuration
auth: {
  username: 'your-username',
  token: 'ghp_xxxxxxxxxxxxx',
}

GitLab

Generate a Personal Access Token:

  1. Go to Preferences → Access Tokens
  2. Create token with read_repository scope
  3. Use the token in configuration
auth: {
  username: 'your-username',
  token: 'glpat-xxxxxxxxxxxxx',
}

Azure DevOps

Generate a Personal Access Token (PAT):

  1. Go to User Settings → Personal Access Tokens
  2. Create token with Code (Read) permission
  3. Use the token in configuration
auth: {
  username: 'your-username',
  token: 'xxxxxxxxxxxxx',
}

🔄 Automatic Synchronization

The module automatically synchronizes repositories when starting the application. To manually synchronize:

curl -X POST http://localhost:3000/sync

💡 Usage with ConfigService

You can inject ConfigServerService into any service:

import { Injectable } from "@nestjs/common";
import { ConfigServerService } from "@sorodriguez/nest-cloud-config-server";

@Injectable()
export class MyService {
  constructor(private readonly configServerService: ConfigServerService) {}

  async getRepositories() {
    return this.configServerService.getRepositories();
  }

  async syncRepositories() {
    await this.configServerService.forceSyncRepositories();
  }
}

📋 TypeScript Types

import {
  ConfigServerModuleOptions,
  RepositoryManager,
  RepositoryType,
  ConfigQueryDto,
  IConfigFile,
} from "@sorodriguez/nest-cloud-config-server";

📄 License

ISC