npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

als-settings

v0.4.3

Published

Add dynamic settings to your project which saved in sqlite db and available for update in routes (optional)

Downloads

6

Readme

Als-settings

being tested

About

Add dynamic settings to your project which saved in sqlite db and available for update.

new in 0.4.0

  • dependency als-sqlite update to 0.5
  • get method fixed
  • global.sqlite = {Model}

new in 0.3.1

  • als-sqlite for saving updated to new version

new in 0.3.1

  • save and get bollean type

new in 0.3

  • not available as middleware
  • settings data has to be function that getting curent settings state
  • Now available process.get and process.set
  • Unset by key set(key)
  • Create new key set(key,value) - if not exsists, creating new setting

new in 0.2

  • save json data

Basic usage

Syntax for initialization:

let getSettings = require('als-settings')
getSettings(settingsFn:function,restore:Boolean)

Parameters:

  • settingsFn - is a function which get curent settings state and has to return new settings state as object
    • object can include objects and arrays
  • restore - if true, restore settings with new state

After initialization, you can use the folowing:

process.settings.keyForSetting // getting setting by key
process.settings.get(key) // deliting setting by key
process.settings.set(key,value) // adding new setting or updating existing

Example

let express = require('express')
let app = express()

let getSettings = require('als-settings')
let dev = true

//restore false by default
getSettings(function(settings) {
   let secret = settings.secret ? settings.secret : require('crypto').randomBytes(64).toString('hex')
   return {
      site_name:'test',
      roles: ['dev','admin','editor','user','subscriber','commentor'],
      secret,
   }
},dev)

app.get('/set/:site_name',(req,res) => {
   req.settings.set('site_name',req.params.site_name) // setting new value to key and update process.settings
})
app.get('/use',(req,res) => {
   // getting value
   return res.end(`<div>${process.settings.site_name}</div>`)
})
app.get('/refresh',(req,res) => {
   req.settings.get('key','value') // updating process.settings from db
   return res.end('done')
})

app.listen(3000)

global.sqlite usage

You can use sqlite db with als-sqlite which available as global.sqlite.Model. The Model allready connected to db and has all existing models inside global.sqlite.Model.models.

Read more in https://www.npmjs.com/package/als-sqlite