global-silo

0.0.1 • Public • Published

global-silo

Creates a single location for server-wide variables.

Accessing variables

all - Retrieves all the store properties and values

get - Retrieves the key-value pair

set - Stores the key-value pair, over-writes the key if it already exists

add - Creates the key-value pair, will not over-write the key if it already exists

rm - Removes the property from the store

cp - Copy the value from one property to another

mv - Move the value from one property to another

Example

In a server.js file:

const express = require('express');
const silo = require('global-silo');
const getBucket = require('./get_s3_bucket');

const app = express();

/* This will supply a single location for variables used server-wide. 
The get_s3_bucket.js file could contain a function that retrieves a file
from an AWS S3 Bucket, which requires the bucket name and a file name variables.
Alternatively, you could pass the variable through as a parameter.
*/
silo.init([
  [ 'bucketName', 'identity-level-of-education-dev-bucket-s3' ],
  [ 'storageFile', 'levels_of_education.json' ],
  [ 'logFile', 'level_of_education_logs.json' ]
]);

app.get('/log-info', (req, res) => res.status(200).send(getBucket(logs.json);

app.listen(process.env.PORT || 8081, function () {
  console.log("Server running on port", port);
});

Readme

Keywords

none

Package Sidebar

Install

npm i global-silo

Weekly Downloads

0

Version

0.0.1

License

Apache-2.0

Unpacked Size

16.9 kB

Total Files

4

Last publish

Collaborators

  • stuft2