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

meseret-utils

v0.0.6

Published

A collection of handy utility functions and middleware compatible with meseret.

Downloads

6

Readme

meseret-utils

A collection of handy utility functions and middleware compatible with meseret.

meseret-utils npm downloads npm code style: prettier

Getting Started

To install, inside a meseret project:

yarn add meseret-utils

# or, using npm:
# npm i meseret-utils --save

Then, we'll need to run the configuration/setup function (called configureMeseretUtils) at our app's entry like:

// maybe, your index.ts

import { ServerApp } from 'meseret'
import { configureMeseretUtils } from 'meseret-utils'

import { serverAppConfig } from './path/to/your/server-app-config'

export const serverApp = new ServerApp(serverAppConfig)

configureMeseretUtils({
  serverApp
})

serverApp.start().catch(console.error)

Utils

Helper Functions
  • C.R.U.D.: a collection of functions (add, get, list, search, edit and remove) that perform read and write operations on MongoDB collections (as modelled by mongoose); these functions include extensive error handling, and highly customizable querying and action plugging.

  • email: an easy way to send an email.

  • Grid: a nice abstraction of GridFS, the large-file-size-capable storage system inside MongoDB.

  • KoaController: a controller super-class that works hand-in-hand with our handle middleware.

  • KoaError: an extension of Error (with support for error code and HTTP status) that is compatible with koa and our handle middleware.

  • password: a pair of functions that assist in an account's password reset process.

  • PhotoGrid: coming soon, in the next few feature releases.

  • transact: an abstraction to quickly support MongoDB's session-based multi-document ACID-compatible transactions; these require MongoDB 4+.

Koa Middleware
  • authenticate: handles account authentication checks using koa-passport and responds to errors graciously.

  • authorize: handles authorization by account roles, after implicitly calling our authenticate middleware.

  • handle: a koa middleware that implicitly calls our transact function on our koa-controller methods and nicely handles our koa-error throws.

  • login: a helper koa middleware to quickly login to an account using koa-passport.

  • logout: a helper koa middleware to quickly logout from an account.

  • sslRedirect: a koa middleware that redirects all HTTP requests to HTTPS in "production" environments (unless other environments are passed to it).

Mongoose Models
  • KeyModel: a mongoose data model used in our password reset functions to store unique keys (tokens).
Types
  • ObjectId: a shortcut for the type mongoose.Schema.Types.ObjectId | string.

License

Proudly, made with ♥ in Addis Ababa.

MIT License © 2019 Kaleab S. Melkie