2.1.4 • Published 2 years ago
osirius v2.1.4
access variables across your server
We recommend using express in order to access the global variables part of the package. The global variables aspect of the package works with servers.
You can also use this package to write JSON files
npm i osirius
global server state
app.js
const express = require("express)
const app = express();
const osirius, {getBolts} = require("osirius)
// global server side state
osirius.use("./siriusbuilder.js");
const thisisatest = (req, res, next) => {
console.log(getBolts("blue")); //[ { key: 'blue', values: { sup: 'hi' } } ]
res.json({ message: "success" });
};
app.listen(3000)
siriusBuilder.js
const { osiriusBuilder, osiriusBuild } = require("osirius");
const hello = new osiriusBuilder("blue", { sup: "hi" });
osiriusBuild(hello.modules());
const itworks = new osiriusBuilder("a word", { hello: "green" });
osiriusBuild(itworks.modules());
creating JSON files with osirius
app.js
const express = require("express");
const app = express();
const { osiriusEnergy, osiriusCloud } = require("osirius");
const osirius = require("osirius)
const port = 3000;
app.get("/standard", (req, res) => {
const hello = { blue: "peach" };
// ⬇️ make a folder ⬇️ if theres already a folder nothing will happen, so you could just write a variable that is a file name, though, the touch method on osiriusCloud returns the string passed through osiriusCloud no matter the circumstance
const blue = new osiriusCloud("leaf/hello/hi/").touch();
// ⬇️ for creation of files with a path
new osiriusEnergy(hello).path(blue);
// ⬇️ for creation of files without a path
new osiriusEnergy(hello).save();
// ⬇️ returns top level, selected folder or file and the next level after that
const aCloud = osirius.cloud("leaf/", true)
console.log(aCloud)
// ⬇️ returns selected folder or file and the next level after that
const aCloud = osirius.cloud("leaf/")
console.log(aCloud)
res.json("complete");
});
app.listen(port, () => {
console.log(`Example app listening on port ${port}`);
});