New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

nest-utilities-client

Package Overview
Dependencies
Maintainers
0
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nest-utilities-client

Provides a generic HTTP service which interfaces with the nest-utilities package.

  • 3.3.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
0
Weekly downloads
 
Created
Source

Provides an extension on your HTTP services which interfaces with API's using the nest-utilities package.

NPM Downloads NPM Version

Basic usage

The package revolves around the CrudService. Extending this service will grant you methods to call upon the endpoints generated by nest-utilities as well as the available query parameters.

import { CrudService } from "nest-utilities-client";
import { IUser } from "../interfaces"

class UserService extends CrudService<IUser> {
  constructor() {
    super("http://localhost:3000/users");
  }
}

HTTP service

Out of the box the CrudService will supplement your extended class with a basic HTTP service to execute your calls. In a lot of cases you'll want to create generic error handlers and define headers to send along with your requests.

You can customize the HTTP service by creating a new class which extends the HTTP service offered by the package. In this new class you will be prompted to implement abstract methods which help you tailor the service with ease.

import { HttpService } from "nest-utilities-client";
import { messageService } from "../services";

class CustomHttpService extends HttpService {
  getHeaders(url: string, init: RequestInit) {
    return {
      "Authorization": localStorage.session
    };
  }

  onRequestError(error: Error) {
    messageService.notify(error.message);
  }
}

import { CrudService } from "nest-utilities-client";
import { CustomHttpService } from "../services";
import { IUser } from "../interfaces"

class UserService extends CrudService<IUser> {
  constructor() {
    super("http://localhost:3000/users", new CustomHttpService());
  }
}

Keywords

FAQs

Package last updated on 12 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc