
Security News
npm Adopts OIDC for Trusted Publishing in CI/CD Workflows
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Organize your API with flexible customization in a breeze. No dependencies.
$ npm i -s root-api
There are 2 steps:
objects
.values
, references to files
and factories
(through functions
or files
). Here is where the root-api
helps.This is a test that demonstrates almost all the parameters in action separatedly:
// STEP ONE: DEFINE THE TREE:
const $api = rootAPI.create({
directory: __dirname + "/lib",
separator: ".",
root: {
classicMessage: "Hi all!",
data: {
strings: {
hello: "hello",
world: "world"
},
externalSource: undefined,
code: undefined,
code800: undefined,
message: undefined,
prop: "code800"
},
getMessage: undefined,
setMessage: undefined,
aboutData: undefined,
}
});
// STEP TWO: DEFINE THE LEAVES:
$api.set({ property: "data.code", value: 200 })
$api.set({ property: "data.code800", file: "data.example.js" });
$api.set({ property: "data.message", factory: "data.message.factory.js" });
$api.set({ property: "getMessage", file: "function.getMessage.js" });
$api.set({ property: "setMessage", factory: "function.setMessage.factory.js" });
await $api.set({ property: "data.externalSource", factory: "data.externalSource.factory.js", with: ["data.strings.hello", "data.strings.world"], promised: true });
$api.set({ property: "aboutData", factory: "function.aboutData.factory.js", scope: "data" });
$api.set({ property: "aboutDataBound", factory: "function.aboutData.factory.js", scope: "data", with: ["data.prop"] });
$api.set({ property: "sum", factory: function() { return 800 + this.code800 }, scope: "data", with: ["data.prop"] });
// STEP THREE: TEST THE RESULTS:
const api = $api.root;
expect(typeof api).to.equal("object");
expect(typeof api.getMessage).to.equal("function");
expect(typeof api.setMessage).to.equal("function");
expect(typeof api.data).to.equal("object");
expect(typeof api.data.externalSource).to.equal("string");
expect(api.data.externalSource).to.equal("hello world x 1000");
expect(api.classicMessage).to.equal("Hi all!");
expect(api.data.message).to.equal("Hi all!!");
expect(api.data.code800).to.equal(800);
expect(api.data.code).to.equal(200);
api.setMessage("okay!");
expect(api.data.message).to.equal("okay!");
To see the complete example, you will have to go to the test
folder.
This logical expression represents the combinations of parameters that makes sense to the internal algorythm:
property & ( factory | file | value ) & ( with )? & ( scope )?
property
indicates, as a string
and using the separator
option which defaults to .
, the property which is going to be modified.( factory | file | value )
indicates the source, and implicitly its type, by which the property is going to be set.
factory
can receive function
or string
. On strings
, it is understood as the path of a file which is a function
module.file
can receive string
as the path of a file which is a function
module.value
can receive any
as the direct value.with
is optional. Used with functions, it indicates the parameters attached to the main function. In the case of the factory
, the factory
's main function is attached only.scope
is optional. Used with functions, it indicates the scope bound to the main function. In the case of the the factory
, the factory
's main function is attached only.This project is licensed under WTFPL
or do What The Fuck you want to Public License
.
You can leave an issue on the repository.
FAQs
Organize your API with flexible customization in a breeze. No dependencies.
The npm package root-api receives a total of 0 weekly downloads. As such, root-api popularity was classified as not popular.
We found that root-api demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
Security News
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.