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 = ;autoAPI;
$ node app.js
var autoAPI = ;autoAPI;
$ node app.js 8000
node_modules/auto-api$ npm start
//angular example$http; //will return every document in a file$http; //will return the document in a _id:1234556$http; //will return the first 10 documents in an array (/anystring/limit/skip)$http; //will return 4 document skipping the first 10 (/anystring/limit/skip)$http;// or$http;/*will save and return a new anystring document,even if you did not pre-loaded any files*/$http;/* will update a document with _id:12456(If not given one, _id will be Date.now(), which is an integer)*/$http//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 -
or
File Loading
In your main application file:
var autoAPI = ;autoAPIpreload = '/path/to/file1' '/path/to/file2'... '/path/to/fileN';autoAPI;
Or on the terminal:
$ node app.js 8000 /home/current_user/filename $ node app.js 8000 /home/current_user/filename1 /home/current_user/filename2 ... /home/current_user/filenameN$ node app.js 8000 ./file1 ./file2 ./file3
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