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

auto-api

v1.4.0

Published

An automated small REST API, with a DB simulator for programming practice or learning

Downloads

4

Readme

auto-api

Small REST API with DB simulation for practice purpouses

The genaral idea is to use GET, POST, PUT, PATCH and DELETE HTTP verbs to access a non secure route to studie front end tecnologies, abstracting the back end. If you post on any route it will create the route and store the data automatically.

Installation

$ npm install auto-api

Usage

var autoAPI = require('auto-api');
autoAPI.load(3000);
$ node app.js (will start on port 3000)
var autoAPI = require('auto-api');
autoAPI.load();
$ node app.js 8000 (will start on port 8000)
node_modules/auto-api$ npm start (will start on port 9000, with nodemon and jshint (dev dependencies required))
//angular example
$http.get('/anystring'); //will return every document in a file
$http.get('/anystring/1234556'); //will return the document in a _id:1234556
$http.get('/anystring/10/0'); //will return the first 10 documents in an array (/anystring/limit/skip)
$http.get('/anystring/4/10'); //will return 4 document skipping the first 10 (/anystring/limit/skip)
$http.post('/anystring', {'name': 'Some Name'});
// or
$http.post('/anystring', {'_id':'some-id', 'name': 'Some Name'});
/*will save and return a new anystring document,
even if you did not pre-loaded any files*/
$http.put('/anystring/12456', {'name': 'Some Name'});/* will update a  document with _id:12456
(If not given one, _id will be Date.now(), which is an integer)*/
$http.delete('/anystring/4561234')//will delete de document with _id:4561234

File preloading example:

###File format: ####text file

{"key1": "value1", "key2": "value2"},{"key1": "value3", "key2": "value4"},{"key1": "value5", "key2": "value6"}

####JSON file -

[
	{"key1": "value1", "key2": "value2"},
	{"key1": "value3", "key2": "value4"},
	{"key1": "value5", "key2": "value6"}
]

or

[
	{"_id": "value1", "key1": "value2"},
	{"_id": "value3", "key1": "value4"},
	{"_id": "value5", "key1": "value6"}
]

File Loading

In your main application file:

var autoAPI = require('auto-api');
autoAPI.preload = ['/path/to/file1', '/path/to/file2',[...] '/path/to/fileN'];
autoAPI.doPreload();

Or on the terminal:

$ node app.js 8000 /home/current_user/filename (will start on port 8000 and pre-load data from file filename)
$ node app.js 8000 /home/current_user/filename1 /home/current_user/filename2 ... /home/current_user/filenameN
$ node app.js 8000 ./file1 ./file2 ./file3 (if the files ar in the applicatio directory)

Features

  • Can consume GET, POST, PUT, PATCH or DELETE
  • It will persist the data in files, simulating a database
  • Can use both limit and skip for listing
  • Perfect to abstract server on Angular studing
  • Can pre load data on starting application (data have to be in an array a json file ot in come separated JS object):
  • Can pre load as many files as needed
  • Can set "_id" as needed