Git Product home page Git Product logo

Comments (1)

jasisk avatar jasisk commented on July 3, 2024

Hi @tkambler.

So sorry this fell off my radar.

So there are a couple of things going on here. First, one thing that meddleware does and, second, one thing that confit does (a module you're using if you're building a kraken-js app). In the example you provided, the second case is what's happening but I'll explain both for posterity.

The Thing that Meddleware Does™

Meddleware has a shorthand syntax for supplying the module. If you don't need to supply a method name or arguments (in other words, when the module name is sufficient), meddleware accepts a string module name for the module property. In other words, these two are equivalent:

{ "router": "./myFancyRouter" }
// ... is equivalent to ...
{
  "router": {
    "name": "./myFancyRouter"
  }
}

The Thing that Confit Does™

Confit is the environment-aware configuration loader we wrote for kraken-js. Each layer of configuration is loaded on top of each previous layer. Objects from the new layer are merged into objects of the old layer.

Two of the config files that confit loads are config/config.json, followed by config/[env].json ([env] replaced with the NODE_ENV in which your app is run). You can think of the config.json as your base config, and the [env].json as the overlaid config that is merged into your base config. Given these files:

// config/config.json
{
  "middleware": {
    "router": {
      "module": {
        "name": "express-enrouten",
        "arguments": [{ "index": "path:./routes" }]
      }
    }
  }
}
// config/dev.json
{
  "middleware": {
    "router": {
      "module": {
        "arguments": [{ "directory": "path:./controllers" }]
      }
    }
  }
}

... your final config will look like this:

{
  "middleware": {
    "router": {
      "module": {
        "name": "express-enrouten",
        "arguments": [{ "directory": "path:./controllers" }]
      }
    }
  }
}

... in the case of a kraken-js app, there is a root config that gets loaded before your config/config.json and the example above is almost exactly the same. All of the root level configs are documented in the kraken-js readme.

Let me know if anything else in unclear or if you have any other questions about this. Again, sorry for the delay!

from meddleware.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.