Inversify throws “Ambiguous match found for serviceIdentifier” when a second binding is attempted

Did my diligence and the following are not the scenario I am experiencing.

Also referred to the Official MultiInject Documentation.


In my inversify.config.ts file I have the following

const SAContainer = new Container();

// Bot Command Handler bindings
SAContainer.bind<ICommandHandler>(TYPES.CommandHandlers).to(AboutCommand);
SAContainer.bind<ICommandHandler>(TYPES.CommandHandlers).to(AccountAgeCommand);

And both files are as follows:

@injectable()
export class AboutCommand implements ICommandHandler {
  // ...
}

@injectable()
export class AccountAgeCommand implements ICommandHandler {
  // ...
}

The exception that is thrown is:

Error: Ambiguous match found for serviceIdentifier: CommandHandlers
Registered bindings:
 AboutCommand
 AccountAgeCommand
 ...stack trace excluded

When I uncomment one of the bindings, so that there is only one, it works as expected. But when I attempt to bind 2 or more in this fashion, I get the error message. What have I missed?

Note: I reiterate. I am not attempting to access these yet. The error occurs during the binding code. There is no attempt in my code to inject, either the Service Locator or the @inject patterns.

npm ERR! It downloads really slow and after sometime the npm just errors and stops altogether

I’m trying to do the “npx create-react-app my-app” and after I enter it, it just becomes blank for like a good minute then starts downloading, but the download bar won’t move but the text is changing every 15 seconds. I’ve installed node.js but I’m not sure if I changed anything from it.

Are there any other ways I can use ReactJS?

I’ve tried more than once and it’s just saying the same error, how do I fix this?
Error Message

Please bare with me it’s my first time trying to use it.

Unhandled Runtime Error Error: Cannot read properties of undefined (reading ‘status’)

I have a Next.js API route that handles a POST request to create a user and perform a redirect. However, when I execute the code, I encounter an error message that says “Cannot read properties of undefined (reading ‘status’)”.

import connect from "../lib/mongodb";
import User from '../model/schema';
import { NextApiRequest, NextApiResponse } from 'next';

export default async function handler(req: NextApiRequest, res: NextApiResponse) {
  try {
    await connect(); // Establish MongoDB connection

    const user = await User.create(req.body);
    
    if (!user) {
      return res.status(400).json({ code: 'No Subscription' });
    }
    
    res.status(302).setHeader('Location', '/').end();
  } catch (error) {
    res.status(400).json({ status: 'Not Subscription Used' });
  }
}

I have already ensured that the necessary dependencies and type imports (NextApiRequest and NextApiResponse) are correctly set up. However, the error persists.

Expected behavior:

The code should establish a connection to the MongoDB database.
It should create a new user using the provided request body.
If the user creation is successful, it should perform a client-side redirect to the root URL (“/”).
If the user creation fails or encounters any errors, it should return an appropriate JSON response with the corresponding status codes and messages.

[Actual Behavior]
The code encounters an error stating “Cannot read properties of undefined (reading ‘status’)”. It seems that the res object is undefined, causing the issue.

how to know RTCDatachannel’s current connection type: host/srflx/prflx/relay?

when local RTCDatachannel connected to remote RTCDatachannel, I wanna to konw the connection type: host/srflx/prflx/relay..

I try to parse the following string, but it’s not the current one which is connected

RTCPeerConnection.localDescription.sdp
RTCPeerConnection.remoteDescription.sdp
RTCPeerConnection.currentLocalDescription.sdp
RTCPeerConnection.currentRemoteDescription.sdp

I can use chrome://webrtc-internals/ to see the connected candidate type

Problem for check if sql request return a value

I haver this request :

const sqlConfig = {
              password: MSSQLPASSWORD,
              database: MSSQLDBTANK1,
              stream: false,
              options: {
                trustServerCertificate: true,             
                enableArithAbort: true,
                encrypt: true
              },
              port: 1433,
              user: MSSQLUSER,
              server: MSSQLIP,
            }
          
            sql.connect(sqlConfig)
              .then(async (pool) => {

             var selectQuery = "SELECT distinct * FROM Active_Number (NOLOCK)INNER JOIN Sys_Users_Detail (NOLOCK) ON Active_Number.UserID = Sys_Users_Detail.UserID WHERE   Active_Number.ActiveID = 80004 AND Sys_Users_Detail.UserName = '"+username+"'";
              return pool.request().query(selectQuery);

              })


              .then('error', err => {
                console.log('You have already voted 1');
            })

              .then((result) =>
              {

                console.log('You have already voted 2');

              })

How to make for count returned result.
Because i need check if sq lrequest is correct.

Can you help me please ?

I have discord js and mssql

THX

Execute DB and every time i have a result

How to fix 403 blank page error on Azure Web Service site & SSH connection?

I’ve recently created a web app on Azure using Express and Node 18. It’s worked for development locally, but when I tried to host it on an Azure web app, I couldn’t get it to show. The site did not show anything, and sent back a 403 error in the console. The same happened when I tried to SSH into the server to get more info:

Pinging app default url...
Ping responded with status code: 403
Checking status, body: {"port":2222,"state":"STOPPED","canReachPort":false,"msg":"Unable to connect to WebApp"}

I’ve tried looking up other solutions, but they all seem to refer to a Dockerfile, which I think is created in the process of sending the app to Azure. I’m not sure how to edit this file, but I seem to be experiencing similar errors (Container didn't respond to HTTP pings on port 8080, failing site start)

I’ve tried setting the Express port to 3000, 443, and 8080, and changing the WEBSITE_PORT and PORT env variables, none of which have changed anything.

import express from "express";
import session from "express-session";

const app = express(); // Create express app

app.listen(process.env.PORT); // Listen on port 8080

I’m quite new to Express and Azure, and the slightly confusing nature of the Azure portal has not helped, so any assistance is greatly appreciated!

ULAR77: Sultannya Situs Judi Slot Gacor Terlengkap di Indonesia Yang Harus Anda Mainkan

DAFTAR DAN LOGIN DISINI ULAR77

Example message received (redacted URL):

[2023-06-19T02:41:12.6561] 463744: [site_audit.worker:warn] query_gapi_psi: api_error url=https://example.com/page. (Gapi_common.E_Request {“error”:{“errors”:[{“domain”:”usageLimits”,”reason”:”rateLimitExceeded”,”message”:”Quota exceeded. Please wait a while and try again.”}],”code”:429,”message”:”Quota exceeded. Please wait a while and try again.”}})

Babel issue babel-preset-react-app . The react app stopped working for me suddenly

One of your dependencies, babel-preset-react-app, is importing the “@babel/plugin-proposal-private-property-in-object” package without declaring it in its dependencies. This is currently working because “@babel/plugin-proposal-private-property-in-object” is already in your node_modules folder for unrelated reasons, but it may break at any time.

I have recently started facing this issue

I tried this following command and. it worked for me
npm install –save-dev @babel/plugin-proposal-private-property-in-object

How do i make groups of shapes or likes of triangle, anchor about its center or corner in p5.js

I am trying to make this collectables anchor about its center and the canyon anchor about its right corner.

 collectable = {
    x_pos: 100,
    y_pos: 310,
    size: 40,
    isFound: false,
  };


fill(255, 215, 0);
    ellipse(collectable.x_pos, collectable.y_pos + 100, collectable.size);
    fill(218, 165, 32);
    ellipse(collectable.x_pos, collectable.y_pos + 100, collectable.size - 10);
    fill(255, 215, 0);
    text("£", collectable.x_pos - 5, collectable.y_pos + 107);
    textSize(collectable.size - 20);
canyon = {
    x_pos: 200,
    width: 100,
  };


rect(canyon.x_pos + 20, 432, canyon.width, 300);
  fill(100, 155, 255);
  rect(canyon.x_pos + 20, 432, canyon.width, 100);
  fill(210, 105, 30);
  rect(canyon.x_pos + 20, 432, canyon.width - 90, 300);
  fill(240, 128, 128);
  rect(canyon.x_pos + 110, 432, canyon.width - 90, 300);

Trying to make this collectables anchor about its center and the canyon anchor about its right corner.

React Context not working properly with nested routing

I’m trying to use React Context in my React application to share data between components. Specifically, I have a RateProvider component that provides a RateContext containing a movieRating function. However, when I try to access the movieRating function in a nested component wrapped with a different context, it throws an error saying “Cannot destructure property ‘movieRating’ of ‘(0, react__WEBPACK_IMPORTED_MODULE_0__.useContext)(…)’ as it is undefined.”

Here’s a simplified version of my code:

// AppRoutes.js
// ...

export default function AppRoutes() {
  return (
    <MovieProvider>
      <AuthProvider>
        <RateProvider>
          <BrowserRouter>
            {/* ... */}
            <Routes>
              {/* ... */}
              <Route
                element={
                  <RateProvider>
                    <MovieDetails />
                  </RateProvider>
                }
                path="/movies/:id"
              />
              {/* ... */}
            </Routes>
            {/* ... */}
          </BrowserRouter>
        </RateProvider>
      </AuthProvider>
    </MovieProvider>
  );
}

// RateProvider.js
// ...
export default function RateProvider({ children }) {


//...

  const showFlashMessage = (message) => {
    setFlashMessage(message);
  };

  const movieRating = async ({ movie_id, content, rating }) => {
    try {
      const ratingResponse = await axios.post(`${apiURL}/comments`, {
        movie_id,
        content,
        rating
      });
      if (ratingResponse.status === 200) {
        setRateData(ratingResponse.data);
        showFlashMessage(`Comment successfully added.`);
      }
    } catch (error) {
      console.error('Error:', error);
    }
  };

//...
    const RateContextValue = {
    movieRating,
    fetchComments
  };

  return (
    <RateContext.Provider value={RateContextValue}>
      {flashMessage && <FlashMessage message={flashMessage} onClose={() => setFlashMessage('')} />}
      {children}
    </RateContext.Provider>
  );
}

//RateMovieModalContent.js
//...

import { OutlinedInput } from '@mui/material';
import React, { useContext, useState } from 'react';
import './index.css';
import RattingStars from '../rattingStars';
import { RateContext } from '../../contexts/RateContext';
import { useParams } from 'react-router-dom';

function RateMovieModalContent() {
  const { movieRating } = useContext(RateContext); // Access the movieRating function from RateContext
//...

I’ve tried moving the RateProvider component around, but it doesn’t seem to solve the issue. How can I properly access the movieRating function from the RateContext in the RateMovieModalContent component?

Any help would be greatly appreciated! Thank you!

Issue with Chatbot: Messages Not Displaying After Clicking Send Button

Problem Description:

I am following a YouTube tutorial on how to build a chatbot using Python and JavaScript. The chatbot UI displays correctly, and the button to open the chatbox popup is working fine. However, when I type a message into the input field and click the send button, nothing happens, and the message doesn’t show up in the chatbox. I’m wondering why this is the case.

Code:

Here is the code for app.py (used to run the app):

from flask import Flask, render_template, request, jsonify

from chat import get_response

app = Flask(__name__)

@app.get("/")
def index_get():
    return render_template("base.html")

@app.post("/predict")
def predict():
   text = request.get_json().get("message")
   # TO-DO: check if text is valid
   response = get_response(text)
   message = {"answer": response}
   return jsonify(message)

if __name__ == "__main__":
    app.run(debug=True, port=5001)

And here is the code for app.js (code for the chatbot itself):

class Chatbox {
  constructor() {
    this.args = {
      openButton: document.querySelector(".chatbox__button"),
      sendButton: document.querySelector(".send__button"),
    };

    this.state = false;
    this.messages = [];
  }

  toggleState(chatBox) {
    chatBox.classList.toggle("chatbox--active");
  }

  onSendButton(chatBox) {
    var textField = chatBox.querySelector("input");
    let text1 = textField.value;
    if (text1 === "") {
      return;
    }

    let msg1 = { name: "User", message: text1 };
    this.messages.push(msg1);

    fetch($SCRIPT_ROOT + "/predict", {
      method: "POST",
      body: JSON.stringify({ message: text1 }),
      mode: "cors",
      headers: {
        "Content-Type": "application/json",
      },
    })
      .then((r) => r.json())
      .then((r) => {
        let msg2 = { name: "Sam", message: r.answer };
        this.messages.push(msg2);
        this.updateChatText(chatBox);
        textField.value = "";
      })
      .catch((error) => {
        console.error("Error:", error);
        this.updateChatText(chatBox);
        textField.value = "";
      });
  }

  updateChatText(chatBox) {
    var html = "";
    this.messages
      .slice()
      .reverse()
      .forEach(function (item, index) {
        if (item.name === "Sam") {
          html +=
            '<div class="messages__item messages__item--visitor">' +
            item.message +
            "</div>";
        } else {
          html +=
            '<div class="messages__item messages__item--operator">' +
            item.message +
            "</div>";
        }
      });

    const chatMessage = chatBox.querySelector(".chatbox__messages");
    chatMessage.innerHTML = html;
  }

  display() {
    const { openButton, sendButton } = this.args;
    const chatBox = document.querySelector(".chatbox__support");

    openButton.addEventListener("click", () => this.toggleState(chatBox));

    sendButton.addEventListener("click", () => this.onSendButton(chatBox));

    const inputNode = chatBox.querySelector("input");
    inputNode.addEventListener("keyup", (event) => {
      if (event.key === "Enter") {
        this.onSendButton(chatBox);
      }
    });
  }
}

const chatbox = new Chatbox();
chatbox.display();

Here is the HTML and CSS code for the chatbot in base.html:

<!DOCTYPE html>
<html lang="en">
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">

<head>
    <meta charset="UTF-8">
    <title>Chatbot</title>
</head>
<body>
<div class="container">
    <div class="chatbox">
        <div class="chatbox__support">
            <div class="chatbox__header">
                <div class="chatbox__image--header">
                    <img src="https://img.icons8.com/color/48/000000/circled-user-female-skin-type-5--v1.png" alt="image">
                </div>
                <div class="chatbox__content--header">
                    <h4 class="chatbox__heading--header">Chat support</h4>
                    <p class="chatbox__description--header">Hi. My name is Sam. How can I help you?</p>
                </div>
            </div>
            <div class="chatbox__messages">
                <div></div>
            </div>
            <div class="chatbox__footer">
                <input type="text" placeholder="Write a message...">
                <button class="chatbox__send--footer send__button">Send</button>
            </div>
        </div>
        <div class="chatbox__button">
            <button><img src="{{ url_for('static', filename='images/chatbox-icon.svg') }}" /></button>
        </div>
    </div>
</div>

<script>
    var $SCRIPT_ROOT = "{{ request.script_root|tojson }}";
</script>
<script type="text/javascript" src="{{ url_for('static', filename='app.js') }}"></script>

</body>
</html>

and here is style.css:

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Nunito", sans-serif;
  font-weight: 400;
  font-size: 100%;
  background: #f1f1f1;
}

*,
html {
  --primaryGradient: linear-gradient(93.12deg, #581b98 0.52%, #9c1de7 100%);
  --secondaryGradient: linear-gradient(
    268.91deg,
    #581b98 -2.14%,
    #9c1de7 99.69%
  );
  --primaryBoxShadow: 0px 10px 15px rgba(0, 0, 0, 0.1);
  --secondaryBoxShadow: 0px -10px 15px rgba(0, 0, 0, 0.1);
  --primary: #581b98;
}

/* CHATBOX
=============== */
.chatbox {
  position: absolute;
  bottom: 30px;
  right: 30px;
}

/* CONTENT IS CLOSE */
.chatbox__support {
  display: flex;
  flex-direction: column;
  background: #eee;
  width: 300px;
  height: 350px;
  z-index: -123456;
  opacity: 0;
  transition: all 0.5s ease-in-out;
}

/* CONTENT ISOPEN */
.chatbox--active {
  transform: translateY(-40px);
  z-index: 123456;
  opacity: 1;
}

/* BUTTON */
.chatbox__button {
  text-align: right;
}

.send__button {
  padding: 6px;
  background: transparent;
  border: none;
  outline: none;
  cursor: pointer;
}

/* HEADER */
.chatbox__header {
  position: sticky;
  top: 0;
  background: orange;
}

/* MESSAGES */
.chatbox__messages {
  margin-top: auto;
  display: flex;
  overflow-y: scroll;
  flex-direction: column-reverse;
}

.messages__item {
  background: orange;
  max-width: 60.6%;
  width: fit-content;
}

.messages__item--operator {
  margin-left: auto;
}

.messages__item--visitor {
  margin-right: auto;
}

/* FOOTER */
.chatbox__footer {
  position: sticky;
  bottom: 0;
}

.chatbox__support {
  background: #f9f9f9;
  height: 450px;
  width: 350px;
  box-shadow: 0px 0px 15px rgba(0, 0, 0, 0.1);
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
}

/* HEADER */
.chatbox__header {
  background: var(--primaryGradient);
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  padding: 15px 20px;
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
  box-shadow: var(--primaryBoxShadow);
}

.chatbox__image--header {
  margin-right: 10px;
}

.chatbox__heading--header {
  font-size: 1.2rem;
  color: white;
}

.chatbox__description--header {
  font-size: 0.9rem;
  color: white;
}

/* Messages */
.chatbox__messages {
  padding: 0 20px;
}

.messages__item {
  margin-top: 10px;
  background: #e0e0e0;
  padding: 8px 12px;
  max-width: 70%;
}

.messages__item--visitor,
.messages__item--typing {
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
  border-bottom-right-radius: 20px;
}

.messages__item--operator {
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
  border-bottom-left-radius: 20px;
  background: var(--primary);
  color: white;
}

/* FOOTER */
.chatbox__footer {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px;
  background: var(--secondaryGradient);
  box-shadow: var(--secondaryBoxShadow);
  border-bottom-right-radius: 10px;
  border-bottom-left-radius: 10px;
  margin-top: 20px;
}

.chatbox__footer input {
  width: 80%;
  border: none;
  padding: 10px 10px;
  border-radius: 30px;
  text-align: left;
}

.chatbox__send--footer {
  color: white;
}

.chatbox__button button,
.chatbox__button button:focus,
.chatbox__button button:visited {
  padding: 10px;
  background: white;
  border: none;
  outline: none;
  border-top-left-radius: 50px;
  border-top-right-radius: 50px;
  border-bottom-left-radius: 50px;
  box-shadow: 0px 10px 15px rgba(0, 0, 0, 0.1);
  cursor: pointer;
}

Additional Context:

I have implemented a chatbot based on the tutorial, but when I type a message and click the send button, nothing happens. I have checked the code, and it seems that the onSendButton() function is not being triggered correctly. I expect the message to be sent to the server using the fetch() function and then added to the chatbox messages using the updateChatText() function.

I would appreciate any help in identifying why the messages are not displaying after clicking the send button. Thank you!

How to increase the line width when hovering the cursor in chart.js?

I know that I can change the width of the line and its points with borderWidth: 1, pointRadius: 1, it works fine.

But how to increase the width of the line and its points when hovering the mouse cursor over a line?
I tried hoverBorderWidth: 2, hoverRadius: 2 as suggested in the docs but with no success.

I tested in Google Apps Script by adding these lines to the html file:

<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script src="https://cdn.jsdelivr.net/npm/chartjs-adapter-date-fns/dist/chartjs-adapter-date-fns.bundle.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/chartjs-plugin-autocolors"></script>

CORS Issue in Next.js 13: Accessing a deployed API route from another Next.js App

I’m currently using Next.js 13.4.7 and trying to set up an API route to be accessible from a browser-based app (also a Next.js app). However, I’ve been encountering some CORS issues.

Here’s my API route, which I’ve implemented according to the Next.js documentation:

export async function POST(request: Request) {
  return new Response("Hello, Next.js!", {
    status: 200,
    headers: {
      "Access-Control-Allow-Origin": "*",
      "Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, OPTIONS",
      "Access-Control-Allow-Headers": "Content-Type, Authorization",
    },
  });
}

I am using the app router. My folder structure looks like:

/app/api/cors-test/route.ts

This route is deployed and works fine when tested with Postman: https://next13-api-tester.vercel.app/api/cors-test

However, when I try to make a request from my browser-based app, I get a CORS error:

Access to fetch at 'https://next13-api-tester.vercel.app/api/test' from origin 'http://localhost:3001' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

This is the request I am making from my (other) app:

const res = await fetch("https://next13-api-tester.vercel.app/api/cors-test", {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      email: "[email protected]",
      project: "123456",
    }),
});

I’ve tried a number of solutions, but nothing seems to work. I am obviously missing something here. Could someone please guide me on how to resolve this CORS issue in my Next.js app?

code can be found here:

https://github.com/owolfdev/next13-api-tester

Convert Table data in a array to multiple objects in array in javascript

Hi all I have a small doubt related to an array. That is sending me data from a table in a single array. so I’m unable to align it properly in a table.so I need some solution for this.

Data coming from array

[

0 3x abcd aezakmi 900 
1 2x defg panjer 800
2 1x hijk  flyhigh 750

]

because of this kind of response, I’m unable to map it in the table

expected data which I’m looking for

[
[{0}{3x}{abcd}{aezakmi}{900}]
[{1}{2x}{defg}{panjer}{900}]
[{2}{1x}{jijk}{flyhigh}{700}]
]

so that i can map them easily in table.

Using a parent’s state in a child component

I’m trying to develop a counter as a child component that increments every second, or perhaps more frequently in the future, but that is turned on or off by clicking a control component in the parent. I put together a related minimum working example that illustrates something I don’t understand.

import React, {useEffect, useState, createContext, useContext} from 'react'                          
                                                                                                     
const TempContext = createContext();                                                                 
const TestChild = () => {                                                                            
  const {masterValue } = useContext(TempContext)                                                     
  const [q, setQ] = useState(0);                                                                     
  console.log('rerender')                                                                            
  useEffect( () => {                                                                                 
    const interval = setInterval( () => {                                                            
      setQ(q+1);                                                                                     
      console.log('observed', masterValue);                                                          
      return () => clearInterval(interval)                                                           
    }, 1000);                                                                                        
  }, [q]);                                                                                           
  return (                                                                                           
  <>                                                                                                 
    {q}. master is {masterValue}                                                                     
  </>                                                                                                
  )                                                                                                  
}                                                                                                    
                                                                                                     
const TestParent = () => {                                                                           
  const [masterValue, setMasterValue] = useState(100);                                               
  console.log('master value is', masterValue);                                                       
  return (                                                                                           
    <TempContext.Provider value={{masterValue}}>                                                     
      <div style={{margin: "30vh"}} >                                                                
    <TestChild />                                                                                    
      <div                                                                                           
      style={{width:300, height:300, 'backgroundColor': "lightblue", padding: "3em"}}                
      onClick={ () => {setMasterValue(-1*masterValue)}}>                                             
          Click me                                                                                   
      </div>                                                                                         
    </div>                                                                                           
    </TempContext.Provider>                                                                          
  )                                                                                                  
}                                                                                                    
export default TestParent;    

I expect this to display a counter that increments up once every second and displays masterValue next to it. I expect that value to change when I click the box and for that change to be reflected in the console log.

Instead, I get no change in the console log except seemingly random intervals (once I’ve clicked the box at least once) and the counter counts up from zero to q every second. My main issue is figuring out how to use the changed (onClick) parent value in the child component, but help with the weird counter behaviour would also be great!