Unable to access the 'singleton' property of an undefined value in Adonisjs

An issue arises when the tender attempts to register a Service of singleton type.

My approach involves utilizing IocContract

AppProvider

export default class AppProvider {
  constructor(
    protected app: ApplicationContract,
    protected $container: IocContract
  ) {}

  public register() {
    // Register custom bindings
    this.$container.singleton(
      'Front/RegraService',
      () => new RegraService()
    )
  }

Error

Cannot read properties of undefined (reading 'singleton')

Answer №1

class ProviderApp {
  constructor(protected appInstance: ApplicationContract) {}

  initiate() {
    this.appInstance.container.singleton('Front/RuleService', () => new RuleService())
  }
}

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

Style the div element with CSS

Is there a way to style a div element within an HTML document using Sencha framework? I have specific CSS properties that I would like to apply to my div. #logo{ position:absolute; top:20%; left:0%; } Below is a snippet of my Sencha code: Ex ...

Once the submission is made, the website will automatically refresh

As I delved into working on a web page utilizing JavaScript, I implemented a jQuery function to validate user input data. I ensured that if the data was incorrect, the function would return false (return false;) and the form would not refresh the page. How ...

Generating a USA map with DataMaps in d3jsonData

I'm trying to create a basic US map using the DataMaps package and d3 library. Here's what I have attempted so far: <!DOCTYPE html> <html> <head> <title> TEST </title> <script src="https://d3js.org/d3.v5.js"> ...

Display Issue with Header Row in React Data Table Component - Full Text Not Visible

Hey there! I've been working with a neat npm package called react-data-table-component. However, I've run into a bit of trouble trying to adjust the width of the table header text. Take a look at the issue here: https://i.sstatic.net/AzqNw.png ...

Using Regular Expressions in Javascript

I have gone through numerous posts with this title, but so far, none of them have addressed my specific query... My requirement is to utilize regex in the following format: "/^ user provided input $/i". The user can include the special regex character * e ...

When the buffer is sent through the socket in NodeJS, the console responds by stating that it is not recognized as a buffer

I've been exploring the implementation of AES encryption in ECB mode and here is the code snippet I'm working with. function encrypt (key, iv, plaintext) { if(algorithm == 'aes-128-ecb') iv = new Buffer(''); var ciphe ...

Exploring the differences between using Node.js JSON.parse during object creation versus when utilizing a getter property

This topic primarily focuses on seeking feedback on whether the current approach is optimal or if there are better ways to handle it. If you have any advice or comments on the content below, even if not directly asked for, please feel free to share. In my ...

Number input field failing to update value upon pressing 'enter'

App features an input element that updates when the user presses enter, clicks away, or clicks the next button. Upon inspecting the element in the developer tools, it was observed that the value attribute updates when the user clicks away or clicks the nex ...

Rollup ESM creates faulty imports

I need to package a TypeScript React app as a component in an ES module or UMD, but the ES bundle generated is producing an invalid JS module. When bundling, I receive the following hints. However, I am unable to find a solution for this. (!) Missing glob ...

Why isn't my onClick event functioning as expected?

I used the handleClick function in an onClick event, but it's showing an error (this is not defined). var Buttons = React.createClass({ getInitialState() { return { field: ':P ' } }, handleClick(field ...

How to effectively handle null values using try..catch statement in typescript

As a beginner, I am learning how to write a try/catch statement in TypeScript. My issue is that there is a function within the "try" block that returns null. How can I implement code in the "catch" block specifically for when the function in "try" returns ...

Create a layered structure using a specified path

I am aiming to create a function that can accept an object path, like { 'person.data.info.more.favorite': 'smth' } and then output a nested object: { person: { data: { info: { more: { favorite: 'smth& ...

The stateParms phenomenon

I have encountered an issue regarding $stateParams that I am trying to comprehend: The code I am using to navigate through states is as follows: In my controller: $scope.goToPath = function ( path, pid ) { $scope.pid = pid; console.log("Curre ...

Is the ID Column in the Minimal Material Table Demo not appearing as expected?

Hey there, I'm in the process of developing a simple demonstration of a material table - Take note that this is a stackblitz link and for some reason, the id column isn't showing up. Here's a snippet from my app.component.ts: import { C ...

Can someone explain the purpose of $event in Angular Material and whether it is necessary when using UI Router?

As I explore this unanswered question, I can't help but ponder if discovering the answer is truly important. My search for information on $event has led me through Angular Material and material docs, yet no mention of it exists. The only reference I f ...

Enabling visibility of overflowing text in dynamically inserted divs without using scroll bars

Is there a way to set the text overflow to visible without scroll bars in dynamically added <div>s? Despite what the documentation says, it doesn't seem to be the default behavior and I'm struggling to understand why. Adding text directly t ...

How can it be that "Function" actually functions as a function?

In JavaScript, there exists a function called "Function". When you create an instance of this function, it returns another function: var myfunc = new Function('arg1','arg2','return arg1+arg2'); In the above example, the vari ...

React Native: Issue with the data section in FlatList

I encountered an issue while using Flatlist to address a problem, but I ran into an error with the data property of my Flatlist. The error message is not very clear and I'm having trouble understanding it ( No overload matches this call. Overload 1 of ...

Google AdSense is unable to detect code fragments within the header of a Next.js website

Hello, I've been trying to set up Google AdSense on my Next.js site, but AdSense doesn't seem to recognize it. I keep receiving an error saying that I need to place the code inside my headers. How can I properly implement this? Below is my _docum ...

Angular Promises - Going from the triumph to the disappointment callback?

It seems like I might be pushing the boundaries of what Promises were intended for, but nonetheless, here is what I am attempting to do: $http.get('/api/endpoint/PlanA.json').then( function success( response ) { if ( response.data.is ...