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-data

v0.2.1

Published

This is a tool for serving data from JSON files. It is meant to be used as a Mock API. This can be useful when you need to develop the front-end separate from the backend.

Downloads

14

Readme

SimpleData

This is a tool for serving data from JSON files. It is meant to be used as a Mock API. This can be useful when you need to develop the front-end separate from the backend.

Installation

npm install -g simple-data

Commands

* sdata can be used in place of simple-data

Initialize a new project in the current folder - simple-data init

Start the server - simple-data start

Generate a resource type in the db - simple-data generate <resource_name>

Import data from a local file - simple-data import <file_path>

Import data from a url - simple-data import <url>

Settings

Initializing a project is not required. When a project is initialized, it creates a simple.json file that includes all settings, and generates a blank database file in data/db.json. The default settings are as follows:

{
  "portNumber": 9000,
  "dataDirectory": "data",
  "dataSource": "db.json",
  "apiStandard": false,
  "namespace": ""
}

Description of Settings

portNumber - Allows you to set the port number that the server will listen on

dataDirectory - The directory that the server will put the data file in. In the future this will also be the location of all factories also.

dataSource - The filename for the actual data file

apiStandard - This is the standard that is used for the API. In the future there will be options for json:api and swagger, but for now only false is allowed. Also feel free to request other standards.

namespace - This is text that should be prepended to all requests. Ex. If you wanted to access a resource called "users", and you set the namespace to "api/v1", you would make the request to http://localhost:<portNumber>/api/v1/users

Requests

At this time the server supports the GET, POST, PUT, PATCH, and DELETE methods. It also has sort and filter functionality for GET requests.

Example Requests

GET http://localhost:9000/users/1

GET (with filters) http://localhost:9000/posts?tag=development&author=4

GET (with sortBy) http://localhost:9000/posts?sortBy=created

POST http://localhost:9000/users/1

PUT http://localhost:9000/users/1

PATCH http://localhost:9000/users/1

DELETE http://localhost:9000/users/1

Data Storage

Currently all data is entered in one file, but this will be optional in the future. A data file currently uses the following format.

Data Format

{
  "resource_example": [
    {
      "id": "1",
      "some_field": "some field value"
    },
    {
      "id": "2",
      "some_field": "a different field value"
    }
  ],
  "other_resource_example": [
    {
      "id": "1",
      "some_field": "some field value"
    },
    {
      "id": "2",
      "some_field": "a different field value"
    }
  ]
}

Data Example

{
  "todos": [
    {
      "id": "1",
      "description": "Get the milk",
      "owner_id": "2"
    },
    {
      "id": "2",
      "description": "Clean out the garage",
      "owner_id": "1"
    },
    {
      "id": "3",
      "description": "Mow the lawn",
      "owner_id": "1"
    }
  ],
  "users": [
    {
      "id": "1",
      "username": "suzyq123"
    },
    {
      "id": "2",
      "username": "johnnie_doe"
    }
  ]
}