Skip to content

Commit

Permalink
feat: bring back TokenInjector for backward compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Sorikairox committed Mar 7, 2024
1 parent e72c95f commit c9ec1c3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
7 changes: 2 additions & 5 deletions spec/injection.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { Module, ModuleMetadata } from '../src/module/decorator.ts';
import { Controller, Get, Post } from '../src/router/controller/decorator.ts';
import { HttpContext } from '../src/router/router.ts';
import { injector } from '../src/injector/injector.ts';
import { Injector } from '../mod.ts';
import { Injector, TokenInjector } from '../mod.ts';

Deno.test('Injection', async (testContext) => {
interface IDBService {
Expand Down Expand Up @@ -106,10 +106,7 @@ Deno.test('Injection', async (testContext) => {
controllers: [SingletonController],
injectables: [
GlobalInjectable,
{
token: 'DB_SERVICE',
useClass: DatabaseService,
},
new TokenInjector(DatabaseService, 'DB_SERVICE'),
{
token: 'CONFIGURATION',
useValue: {
Expand Down
4 changes: 4 additions & 0 deletions src/injector/injectable/constructor.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { Constructor } from '../../utils/constructor.ts';

export type InjectableConstructor = Constructor;
export class TokenInjector {
constructor(public useClass: InjectableConstructor, public token: string) {
}
}
export type UseClassInjector = {
useClass: InjectableConstructor;
token: string;
Expand Down
6 changes: 3 additions & 3 deletions src/router/websocket/payload.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export interface WebSocketPayload<T = unknown> {
topic: string;
data: T
}
topic: string;
data: T;
}

0 comments on commit c9ec1c3

Please sign in to comment.