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

simple-dyno

v0.1.1

Published

Wrapper around AWS DynamoDB SDK to make things easier

Downloads

14

Readme

simple-dyno

Build Status

Easy to use, minimalistic wrapper for AWS DynamoDB

Installation

$ npm install simple-dyno

Features

  • Easy way to create a model, keeping your code consistent and saving it to DynamoDB
  • Serializers to format your (json) response
  • Validation based on Joi
  • Encryption using bcrypt for your passwords
  • Local DynamoDB for testing purposes

Methods

To create a new entry, and options can include {skipValidation: true}:

Model.create(attributes, options)

To get an entry or multiple entries:

Model.get(keyValues)

To update an entry, and options can include {skipValidation: true}:

Model.update(keyValues, attributes, options)

To delete an entry:

Model.destroy(keyValues)

To perform a scan operation (not recommended):

Model.find(attributes)

To query using a secondary index:

Model.query(indexName, attributes)

To serialize the response attributes:

Model.serialize(response, options)

To run a local DynamoDB (which runs on Java), by default runs in memory but you can also store on disk using {inMemory: false} as options:

SimpleDyno.local(options)

To set the config, which you can pass the following options {accessKeyId: '', secretAccessKey: '', region: ''}:

SimpleDyno.config(options)

Example (in this case the config is set by default by AWS and assumes tables are already created)

// Import deps
import { Model } from 'simple-dyno';
import Joi from 'joi';

// Add your own methods
class UserModel extends Model {
  myAwesomeMethod(obj) {
    return obj.firstName+obj.lastName;
  }
}

// Create model instance
var User = new UserModel({
  table: 'users',
  hashKey: 'email',
  serializers: {
    default: ['email'],
    scary: ['access_token', 'password']
  },
  schema: {
    email: Joi.string().email(),
    access_token: Joi.string(),
    password: {
      format: Joi.string().regex(/[a-zA-Z0-9]{3,30}/),
      encrypt: true
    }
  }
});

var userObj = yield User.create({email: '[email protected]', access_token: 'aW12k3KDASsd012Ms1Mf29Mc7', password: '******'})
return User.serialize(userObj, {format: 'scary'});

Example of running the local environment

// Import deps
import * as SimpleDyno from 'simple-dyno';

// Start a local DynamoDB
yield SimpleDyno.local();

// Create accociated tables for the following model(s)
SimpleDyno.load(User);

Todo

  • Fix CI by allowing Java to run on Travis
  • Migrations
  • Better docs (explain how AWS works)

How to contribute

Please create a pull request, make sure to include and update the tests and that they're working. And don't forget to build the minified version (with babel) with make simple-dyno.js.

Running tests

Use make test to do a test run using Mocha.

Legal stuff (MIT License)

Copyright (c) 2016 Awkward.

Distributed under MIT license.