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

casimircore

v0.11.17

Published

The core modules for the Casimir webapp framework

Downloads

17

Readme

Casimir Core

Build Status Coverage percentage NPM version Dependency Status Slack Channel

js-standard-style

The core modules for the Casimir webapp framework

Install

$ npm i --save casimircore

Features

var casimir_core = require('casimircore')()

console.log(casimir_core)

{
  server: {
    http_server,
    port,
    ssl,
    pub_sub,
    sockets,
    io_server
  },
  Error: 'Error Middleware',
  Router: 'Custom Router with authentication and validation',
  logger: {
    info,
    debug,
    error,
    warn
  },
  properties: properties,
  db: {
    init,
    get_model
  },
  authentication: {
    verify_token,
    verify_specific_user_token,
    check_access
  }
}

Authentication

var verify_callback = function (jwt_token, req, res, next) {
  get_user_by_token(jwt_token, function (err, user) {
    if (err) return next(err)
    req.user = user
    next()
  })
}

var access_callback = function (req, res, next) {
  // reaches here if there is no req.user
  res.status(401).send('Not Authorized')
}
 
var authentication = casimir_core.authentication(verify_callback, access_callback)

DB

var mongoose = require('mongoose')
var db = casimir_core.db
var settings = {
  user: 'user',
  pass: 'password',
  host: 'host.mongodb.com',
  port: 27000,
  name: 'testDB',

  // with URI - if provided, all previous connection settings are ignored
  uri: 'mongodb://user:[email protected]:27000/testDB',

  // mongoose models directory
  dir: './db'
}
db.init(settings, mongoose, function (err, mongoose) {
  if (err) return console.error(err)
  console.log('connected to db')
})

Error

var env = process.env.NODE_ENV
var error = casimir_core.error(env)

Logger

var env = process.env.NODE_ENV
var logentries_api_key = 'fdsfdf23fewfew'

var log_settings = {
  env: env,
  logentries_api_key: logentries_api_key,
  log_dir: './log'
}

var logger = casimir_core.logger(log_settings)

// Can Actually run over normal console with logger
console.log = logger.info
console.error = logger.error
console.warn = logger.warn
...

Properties

var config_dir = './config'
var properties = casimir_core.properties(config_dir)

RequestId

var settings = {
  secret: 'secret',
  namespace: 'servername'
}
var requestid = casimir_core.request_id(requestSettings)

Router

var fs = require('fs')
var GET_public = {
  "/path": {
    "function_name": "File.Function",
    "params": ["param1","param2"],
    "optional": ["optionalParam"],
    "users": ["optionalPrivateUsers"]
  }
}
fs.writeFileSync(routes_dir + 'GET-public.json', GET_public) // can be similarly done for POST, PUT, DELETE and private
var controllers_dir = './controllers/'
var routes_dir = './routes/'
var router = casimir_core.router(routes_dir, controllers_dir, authentication)

Server

var validator = require('./validator.js')
// Add custom framwork modules for server
properties.modules = {
  validator: validator,
  router: router,
  error: error,
  logger: logger,
  requestid: requestid
}
// Set server and server port
var server = casimir_core.server(properties)

Testing

$ cd /"module-path"/casimircore
$ npm test

License

Apache-2.0