1.0.0 • Published 9 years ago

config-center v1.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
9 years ago

config-center

Description

Server for property centralized configuration. Properties and values are stored in a MongoDB database with the following formmat :

{
    "_id" : ObjectId([..]),
    "env" : "dev",
    "application" : "APP",
    "name" : "mongo.url",
    "value" : "https://www.google.fr/"
}

Availables queries available for instance

  • GET /prop/:app/:env:/key

    Returns the value of a single properties.

  • GET /prop/:app/:enn

    Returns a JSON object containing all configuration properties and values,like :

    {
      "mongo.host": "localhost",
      "mongo.port": 27017,
      "mongo.collections": [
         "properties",
         "configs",
         "applications",
         "servers"
         ]
    }
  • GET /prop/:app

    Get all environement configuration properties, returns a JSon object with environment labels as keys and property objects as value, example :

    {
     "dev": {
       "mongo.host": "wks136\ ",
       "mongo.collections": [
         "properties",
         "configs"
         ],
       "mongo.port": 27017
     },
     "preprod": {
       "mongo.host": "localhost",
       "mongo.collections": [
         "aa",
         "bb",
         "cc"
         ],
       "mongo.port": 27017
     },
     "prod": {
       "mongo.host": "localhost",
       "mongo.port": 27017,
       "mongo.collections": [
         "properties",
         "configs",
         "applications",
         "servers"
         ]
     }
    }
  • POST /prop/:app/:env:/key and body as text/plain value

    ALlow to create a new configuration property in the database.

  • PUT /prop/:app/:env:/key and body as text/plain value

    Allow to update a configuration property in the database. If you try to update an unixisting property, the server creates it.

  • POST /admin adn body as application/json

    Admin function for shutting dow the server. The JSon body must contain a "pass" property with the admin password. Exemple :

    {
      "pass" : "TheRedFoxIsRunningFast"
    }

Dependencies

"dependencies": {
  "body-parser": "^1.12.4",
  "express": "^4.12.4",
  "log4js": "^0.6.25",
  "mongojs": "^0.18.2",
  "q": "^1.4.1"
}

Starting

npm install

Please review server configuration in file config.js for HTTP port définition and MongoDB url and collection name.

var Config = {

  logLevel: Log4JS.levels.DEBUG,

  http: {
      port: 8000,
      adminPass: 'theRedFox',
      routeDefDir: "./routes",
      routes: {
        ADMIN_ENDPOINT:      "/admin",
        APP_GET_UNQ_PROP:    "/prop/:app/:env/:key",
        APP_GET_ENV_PROPS:   "/prop/:app/:env",
        APP_GET_ALL_PROPS:   "/prop/:app"
      }
  },

  mongo: {
    url: 'localhost/ConfigCenter',
    collections: [ 'properties', 'appEnv', 'appEnvProps'  ]
  }
};

Roadmap and ideas

  • Review Admin shutdown ?
  • Access security to avoid unauthorized access ?