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

@ngflix/feign

v0.0.3

Published

### Feign makes writing http clients easier

Downloads

8

Readme

@ngflix/feign

Feign makes writing http clients easier

Feign is an Angular 5+ package for creating services that can be used to call backend parties, it's based on HttpClientModule provided by angular. Feign's first goal was reducing boilerplate.

Installation

Install @ngflix/feign from npm: npm install @ngflix/feign --save

How does Feign work?

Create a service class and add some annotatons

// posts-feign.service.ts
import { FeignClient, RequestMapping, RequestBody, PathVariable } from '@ngflix/feign';
import { Observable } from 'rxjs';

@FeignClient({
  path: 'https://jsonplaceholder.typicode.com',
  name: 'postService'
})
export class PostService {
  @RequestMapping({ method: 'GET', value: 'posts' })
  public getAll(@RequestParam('order') order: 'desc' | 'asc', @RequestParam('date') date: Date): Observable<Post[]> {
    return null;
  }

  @RequestMapping({ method: 'POST', value: 'posts' })
  public createOne(@RequestBody post: Post): Observable<Post> {
    return null;
  }

  @RequestMapping({ method: 'GET', value: 'posts/{id}' })
  public getOne(@PathVariable('id') postId: string): Observable<Post> {
    return null;
  }
}

...

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  posts$: Observable<Posts[]>;

  constructor(private service: PostService) {
    this.posts$ = service.getAll('desc', new Date());
  }
}

To register the module within your application:

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppComponent } from './app.component';
import { PostService } from './posts-feign.service';
import { NgFeignModule } from '@ngflix/feign';

@NgModule({
  declarations: [AppComponent],
  imports: [BrowserModule, NgFeignModule.forRoot()],
  providers: [PostService],
  bootstrap: [AppComponent]
})
export class AppModule {}

decorators:

@FeignClient

add meta data to service shuch as name, path, and interceptor

@RequestBody

The @RequestBody annotation indicates a paramer that should be used in the body of the request.

@Headers

Feign supports settings headers on requests either as part of the api or as part of the client depending on the use case.

@PathVariable

Replace a dynamic variable on the path by the parameter annotated.