Effective implementation of Ts.ED BullMQ during server initialization

Recently, I started using Tsed(newb) and wanted to incorporate the BullMQ plugin into my project.

I needed to run a job immediately after the server starts, but I struggled with implementing it correctly. I referred to this helpful guide here and attempted the following code snippet:

import { JobDispatchService } from "./services/jobDispatchService";
// Code snippet from: https://tsed.io/tutorials/bullmq.html#dispatching-jobs

export class Server {
  @Inject()
  app: PlatformApplication;

  @Inject()
  dispatcher: JobDispatchService;

  @Configuration()
  settings: Configuration;

  $beforeRoutesInit(): void {
    // Middleware setup
  }

  $afterRoutesInit(): void {
    // Log error message
    this.dispatcher.doSomething();
  }
}

Upon starting the server, I encountered the following error:

[2023-12-15T01:09:33.035] [DEBUG] [TSED] - Start server...
[Error log details...]

The error message indicated that 'this.injector.getMany' is not recognized as a function. I will need to review my code and investigate further to troubleshoot this issue.

Answer №1

It appears that the issue you are experiencing is due to incorrect dependencies installed in your project. One of the guidelines of the Ts.ED framework is to maintain the same version for all @tsed/* packages, with the exception of @tsed/logger.

WARNING

When upgrading Ts.ED dependencies, it is crucial to adhere to this rule:

Maintain consistent versions for all @tsed/* packages (excluding @tsed/logger) to avoid errors. Specify the version for each Ts.ED package as follows:

{
  "dependencies": {
    "@tsed/common": "7.53.0",
    "@tsed/di": "7.53.0",
    "@tsed/core": "7.53.0",
    "@tsed/exceptions": "7.53.0",
    "@tsed/plaftorm-express": "7.53.0",
    "@tsed/swagger": "7.53.0"
  }
}

If you need a prompt resolution to your issue, we recommend opening an issue directly on GitHub.

Thank you and see you soon!

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The Microsoft EDGE browser is encountering a XHR HTTP404 error when trying to access a TypeScript

While debugging a Typescript web application in Visual Studio 2015 and using the Microsoft EDGE browser, an error is reported as follows: HTTP404: NOT FOUND - The server cannot locate anything that matches the requested URI (Uniform Resource Identifier). ...

What techniques does Angular2 use to handle dependency injection?

When working with Angular2 components, I know that to inject a dependency, you simply annotate an argument in the constructor, like how ThingService is injected here. However, what I am wondering is how Angular actually knows what to inject at runtime. A ...

Tips for tidying up duplicated typescript content sourced from a pre-existing library

Seeking guidance on implementing best practices and gaining a better understanding of my approach. After discovering the library react-google-calendar-api, I successfully installed it using npm in my React project. However, I wanted to expand its function ...

Storing numerous string labels and arrays in a TypeScript associative array

I am currently developing a mobile app using Ionic 4 where I need to store various labels and arrays in an associative array. However, I am encountering challenges when it comes to initializing the array, adding new items to it, and updating existing ones ...

Create a new instance of the TypeScript singleton for each unit test

I have a TypeScript singleton class structured like this: export default class MySingleton { private constructor({ prop1, prop2, ... }: MySingletonConfig) { this.prop1 = prop1 ?? 'defaultProp1'; this.prop2 = prop2; ...

Utilizing Dynamic URLs in Kendo for Data Binding or Attributes on List Elements

I am facing an issue with routing two menu items conditionally using Kendo Jquery/MVVM. Originally, I had set the value in a data-href tag and it was displaying the URL correctly. However, I now need to dynamically load a URL based on certain conditions. T ...

Node.js does not allow the extension of the Promise object due to the absence of a base constructor with the required number of type

I'm trying to enhance the Promise object using this code snippet: class MyPromise extends Promise { constructor(executor) { super((resolve, reject) => { return executor(resolve, reject); }); } } But I keep encou ...

What is the easiest way to retrieve a basic date with the month represented by a numerical

Struggling to retrieve the date in the format "Oct 29". I attempted using split but it varies every day. This is what I've come up with so far. let currentDate = new Date().toLocaleDateString('en-US', { month: 'short', day: 'n ...

Tips for displaying the string value of an elementFinder when encountering an error in protractor

I have the following code snippet: export async function waitTillClickable(e: ElementFinder): Promise<ElementFinder> { const conditions = EC.visibilityOf(e); await browser.wait(conditions, DEFAULT_TIMEOUT, `Element did not return ...

Issue with setting value using setState in TypeScript - what's the problem?

Every time I attempt to update the value of currentRole, it appears highlighted in red. Here is a screenshot for reference: const Container: React.FC<ContainerProps> = ({ children }) => { const [role, setRole] = useState<string>(); useE ...

Choose all the checkboxes that use Knockout JS

Struggling with implementing a "select all" checkbox feature as a Junior developer on a complex project utilizing knockout.Js and Typescript. I can't seem to figure out how to select all existing checkboxes. Here is the HTML: <td> <inp ...

What is causing the error TS2339 to be thrown when attempting to access a class property in this TypeScript illustration: "Property 'text' does not exist on type 'T'"?

Could someone provide insight into why attempting to access a class property in this scenario is resulting in the error message error TS2339: Property 'text' does not exist on type 'T'. Here is the TypeScript code: class Base { rea ...

Determining the property type in Typescript based on the value of another property

Unique Code interface Order { customer: Customer, address: Address } interface Customer { name: string } interface Address { firstLine: string } interface OrderUpdateRequest { key: 'customer'|'address', value: ...

How to send empty values in Angular4 HTTP post request to web API

Attempting to call an http post method from an Angular 4 component to a web API is resulting in empty values being returned. Even when checking the request using postman, the values are still empty. Here is the http post call from the component file: Ed ...

Issues arise when trying to implement Angular class and it does

I'm currently facing some challenges using classes in Angular to simplify my coding process. So far, I haven't been able to get it to work properly. Below is the code snippet I'm working with and the error message that pops up: import { Wiz ...

Verifying input for Numeric TextField

The text field being used is: <TextField variant="outlined" margin="normal" id="freeSeats" name="freeSeats" helperText={touched.freeSeats ? errors.freeSeats : ''} error={touched.freeSeats && Boolean(errors.fre ...

Function in Typescript that accepts an extended interface as a parameter

I am facing an issue with my interface named "Example" which has a function type called "exampleFunction". The problem arises when this function takes a super class as an input parameter because TypeScript is reporting an error. It states that I cannot use ...

Creating a TypeScript shell command that can be installed globally and used portably

I am looking to create a command-line tool using TypeScript that can be accessed in the system's $PATH once installed. Here are my criteria: I should be able to run and test it from the project directory (e.g., yarn command, npm run command) It must ...

Rearrange the provided string in a particular manner

Looking to transform a string like '12:13:45.123 UTC Sun Oct 17 2021' into 'Sun Oct 17 2021 12:13:45.123 UTC' without calling slice twice. Is there a more elegant and efficient way to achieve this? Currently using: str.slice(18)+&apo ...

Enhance Tuple in Angular Component Properties

When using React, state variables can be created like this: const SomeComponent = ({ someProp }) => { const [value, setValue] = useState<boolean>(false); } I wonder if there is a similar way to achieve the spread of a tuple within an Angular co ...