Skip to content

stackra-inc/ts-http

Repository files navigation

@stackra/ts-http

npm version MIT license TypeScript


@stackra/ts-http

Middleware-driven HTTP client for TypeScript — axios underneath, decorator-based middleware registration, and DI integration via @stackra/ts-container.

Installation

pnpm add @stackra/ts-http

Features

  • 🔗 Axios-based HTTP client
  • 🎭 @Middleware() decorator for declarative middleware registration
  • 💉 DI integration — inject HttpService anywhere
  • 🔄 Request/response interceptor pipeline
  • 🏗️ HttpModule.forRoot() / forFeature() pattern
  • 🔧 Per-service middleware overrides

Quick Start

import { Module } from '@stackra/ts-container';
import { HttpModule } from '@stackra/ts-http';

@Module({
  imports: [
    HttpModule.forRoot({
      baseURL: 'https://api.example.com',
      middleware: [AuthMiddleware, LoggingMiddleware],
    }),
  ],
})
export class AppModule {}
import { Middleware, Injectable } from '@stackra/ts-container';
import { HttpService } from '@stackra/ts-http';

@Middleware(AuthMiddleware)
@Injectable()
class UserService {
  constructor(private http: HttpService) {}

  async getUsers() {
    return this.http.get('/users');
  }
}

License

MIT © Stackra

About

Middleware-driven HTTP client for TypeScript — axios underneath, decorator-based middleware registration, and DI integration via @stackra/ts-container.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages