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

sweet-request

v1.0.5259

Published

sweet request developed with solid architecture

Downloads

5

Readme

sweet-request

Total abstraction of http request with standalone architecture if using (S.O.L.I.D) principles.

Helps you bring all your api requests and models in one place.

Finally Adding Readme documentations for this project!

Here are basic usage

First

install via npm

npm install sweet-request

or clone git repo.

create a remote folder with the following folder structure

    ---remote
        ---model
            ---all models files here
        ---controller
            ---all controller files here
        ---api
            ---all api files here

create your models eg. User.tsx

User.tsx

export class UserModel{

    public email:string;
    public role:string;

    constructor(email:string,role:string){
        this.email=email;
        this.role=role;
    }

    public static fromJSON(json){
        return new UserModel(json.email,json.role);
    }
}

inside the api folder

UserApi.tsx

export class UserLoginApi extends RequestManager<DataResources<ResponseMessage>,requestprop>{

    constructor(form:FormData){
        super(RequestMethod.POST,"api/login",{data:form})
    }

    //executes after your request is complete
    public data(data:any):DataResources<ResponseMessage>{
        return new DataSuccess(ResponseMessage.fromJson(data));
    }
}

export class UserRegisterApi extends RequestManager<DataResources<ResponseMessage>,requestprop>{

    constructor(form:FormData){
        super(RequestMethod.POST,"api/register",{data:form})
    }

    //executes after your request is complete
    public data(data:any):DataResources<ResponseMessage>{
        return new DataSuccess(ResponseMessage.fromJson(data));
    }
}

inside the controller folder

UserController.tsx

export class UserController{

    public static function login(form:FormData){
        return new UserLoginApi(form).sendRequest();
    }

    public static function register(form:FormData){
        return new UserLoginApi(form).sendRequest();
    }

}

inside the main folder

App.tsx

const =  App()=>{

const submit=(ev)=>{
    ev.preventDefault();

    //send login request here
    UserController.login(form)
    .then(data=>console.log(data.message))
    .catch(err=>console.log(err.message));
}

return <>{/*Login Form Here....*/}</>
}

RUN

npm run dev for vite

npm start for create-react-app

Buy me coffee Next time

for more colloborators feel free

Thank you