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

create-sample-users

v1.1.0

Published

Create sample user data (fixture) for suirdemo app

Downloads

5

Readme

Overview

This was written to generate sample "user" fixture data for a project where Users author Posts and make Comments on Posts authored by other Users. Any User can become a Follower of another User, and that relationship is noted both in the data associated with the Follower and the User being Followed.

This is presently hard-coded to get input from the file /tmp/generated-users.json, with data generated by https://randomuser.me/ using code equivalent to the following:

var fs = require('fs');
var SyncRequest = require('sync-request');
url = 'https://randomuser.me/api/?format=pretty&inc=email,login,registered,picture&nat=au,br,ca,ch,de,dk,es,fi,fr,gb,ie,nl,nz,us&results=100&seed=7c93110b8c5d4c87'
resp = SyncRequest('GET', url);
data = resp.getBody().toString();
fs.writeSync(1, data);

To write fully-formed user data to, e.g., /tmp/users.json, from this project's project root, run the following:

$ node demoCreateSampleUsers.js > /tmp/users.json

It's Not as Simple As It Looks

First, notice that all IDs (for users, comments, posts) are UUIDs. Each following and follower user ID matches an actual id property of a different, unique user. Getting that right took a downright embarrassing amount of flail.

Future Enhancements

Rather than rely on input provided by a separate script, It Would Be Very Nice If this package incorporated the data-generation code, becoming far more self-contained in the process. It Would Also Be Very Nice If, when doing so, the randomisation seed fed to randomuser.me could be specified, making the generated data repeatable. This would in turn be highly useful for, e.g., CI.

By default, we generate 99 users using the randomuser.me script. Ideally, this should also be configurable.

Legalities

Copyright © 2017 by Jeff Dickey, and made freely available under the MIT License.

Participants in this project agree to uphold and be bound by the Contributor Covenant 1.4 Version 1.4 or any later version.