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

easy-crud-frontend

v1.0.1

Published

easy way to build a frontend crud repository

Downloads

118

Readme

easy crud frontend

https://github.com/Dvirus97/easy-crud-frontend

This package help create fast basic curd api.

use clientService

extend IBaseModel in your types for this package

// clientService is a singleton service
const service = clientService;
// set the url of the server
service.setBaseUrl("http://localhost:3010");

// you can also write it like this:
const service = clientServices.setBaseUrl("http://localhost:3010");

// register entity type to the service.
service.register("person")
// you can pass options
service.register("person", {
    updateDataOnChange: true;
    pollingInterval: 2000;
    pollingRetries: 2,
    override: true
});

// you can also register many types at ones.
// if you pass options, the types will share the same options
service.register(['person', 'car', 'table']);

// listen to changes of this type from the server
// this method emit value only if there are changes in the data base on `version` property
service.select$("person").subscribe(...)

you can use polling to keep the data up to date

// start polling only for a specified type
service.polling.start("person");
// start polling for all registered types
service.polling.start();

// same for stop
service.polling.stop();

use crud operations

const p1 = { id: "1", type: "person", name: "name1" };
service.createEntity(p1);

p1.name = "name2";
service.updateEntity(p1);

service.deleteEntity(p1);

there are more operations

const p1 = { id: "1", type: "person", name: "name" };

// all of there methods are one time stream. they are complete after one emit
getOne(p1).subscribe();
getAll("person").subscribe();
addOne(p1).subscribe();
updateOne(p1).subscribe();
updateMany("person", [p1, p2]).subscribe();
deleteOne(p1).subscribe();
deleteAll("person").subscribe();

but there it also custom action

service.customAction("person", "hello", "POST", { data: "world" }).subscribe();

Other things in this package

HttpClient

use axios and rxjs to create observable based http request.

const http = new HttpClient();
http.get("path").subscribe((res) => console.log(res));
http.post("path", data).subscribe((res) => console.log(res));
http.put("path", data).subscribe((res) => console.log(res));
http.patch("path", data).subscribe((res) => console.log(res));
http.delete("path").subscribe((res) => console.log(res));

Compare

compareItems()

pass 2 objects and check if the are the same. if there is a version property, it compare by version

a.version == b.version

if there is no version property, it compare by json

JSON.stringify(a) == JSON.stringify(b)

isDataChanged()

pass 2 arrays and check if they are equal. it use compareItems() function to compare


smartPolling()

call a function in an interval. if more than one subscribers are listening, they will get the same data.

function foo() {
  const name = "value";
  return of(name); // of() in rxjs convert any value to observable
}

const polling = smartPolling(foo, 1000);
const subscription = polling.subscribe((x) => console.log(x));

setTimeout(() => subscription.unsubscribe(), 4000);

/*
logs:
value // after one sec (1)
value // after one sec (2)
value // after one sec (3)
value // after one sec (4)
//  stop polling
 */