Nuxt build – fail to add web component dependency

I have a monorepo with stencil web components and vue wrapper components offered by Stencil using VueOutputTarget.
The component works fine in dev mode but when I run build mode it complaints about entry file not found.

I observed that these are included in dev mode but not in build mode.

hello.oqCrayH6.js:1 TypeError: Failed to fetch dynamically imported module: http://localhost:3000/_nuxt/my-component.entry.js undefined

enter image description here

Next JS: The “path” argument must be of type string or an instance of Buffer or URL

I am trying to parse a file sent with fetch using formdata.

  const [resumeFile, setResumeFile] = useState(null);
  const [reviewResult, setReviewResult] = useState(null);

  const handleFileChange = (e) => {
    setResumeFile(e.target.files[0]);
  };

  const handleSubmit = async (e) => {
    e.preventDefault();

    try {
      const formData = new FormData();
      formData.append('resume', resumeFile);
      const response = await fetch('/api/analyze_resume', {
              method: 'POST',
              body: formData,
              headers: {
                // Note: No need to set 'Content-Type' for FormData as it is automatically set
              },
            });

      const responseData = await response.json();
      setReviewResult(responseData);
    } catch (error) {
      console.error('Error submitting resume:', error);
    }
  };

When I try getting the path to read the file on the server I get this error.

server.post('/api/analyze_resume', async (req, res) => {
  try {
    const resumeText = await extractTextFromResume(req.files.resume.path);
    }
})

Proper String Syntax In JavaScript

I am trying to configure the Weather Desklet by Chris Hastie in Linux Mint 21.2, Cinnamon Desktop.
As far as I can tell, this app is no longer being maintained. I posted a qusestion over a month ago, to no avail, and clicking on the links takes me to a dead end. I have since attempted to edit the desklet.js, the file that powers the app, myself.

After spending all day and getting various error messages in Cinnamon’s Looking Glass log, I am stuck on the following error:

info t=2024-01-17T23:03:25Z bbcwx (instance 34): refreshing forecast at 23:03:25
warning t=2024-01-17T23:03:25Z Error retrieving address https://api.weather.com/v2/pws/observations/current?stationId=MYSTATIONID&format=json&units=e&apiKey=**=**MYAPI. Status: 401: Unauthorized

where MYSTATIONID is the id for my personal weather station; and MYAPI is the api key bestowed by Weather Underground upon signing up at their site.

You will note the second equal sign, in bold. Ideally, it shouldn’t be there. the syntax of the url calls for only ONE equal sign between the text apiKey and the actual key itself. Therein lies my problem.

I am enclosing the desklet.js file that I have been working with edited for security. Please note the equal sign in line 1310, column 59 – I have to have that there, or all the text in the desklet disappears and I get another error message. Please also note the similar equal sign at line 1625, col 115. If that’s not there, same thing happens. The text in the app disappears and the error message respawns. If I include the api key after said equal sign, the key gets duplicated in the url, even when I remove it from line 1310.

It may be worth taking a look at the block of code from lines 1645-1655, particularly line 1646 and the function beginning at line 1652 to help with the analysis. I commented out most of the code in between those two because it was altering the syntax of the url needed to return the meteorological data and generating various error messages.

If I can find a way to alter the syntax of the url, thereby eliminating the second =, I may be able to retrieve the data from the Weather Underground site.

Any assistance is greatly appreciated.

Override browser “undo” key command in Javascript?

I’m creating an application with undo/redo functionality, and would like to utilize keyboard shortcut functionality to trigger this behavior, e.g. cmd+Z

Per the MDN documentation, it appears possible to bind to the “Undo” key event.

My current code looks like this.

document.onkeydown = checkKey;

function checkKey(e) {
    if (e.key === "Undo") {
        e.preventDefault();
        undo();
    }

But it’s still triggering the browser’s default undo action (which in the case of Arc goes to a different tab).

Elsewhere on StackOverflow, I see some old solutions involving using keyup and keydown for specific event.keycodes, which works for me… but per MDN those are deprecated and I’d like to avoid it if possible. Wondering if there’s a better, modern solution using e.key

Thank you in advance!

Get Variable from JS into form Input (after get data from Spin)

can Help me, I Went to get data on the SPIN of wheels from JS to Mysql

I trial GET data to Form input, but can’t get data Spin.

My Expectation if spin stops, the user clicks SUBMIT data and Updates data to MYSQL

Thanks All for help

code

HTML Input:

<form method="post" action="submitaction.php" enctype="multipart/form-data" >
    <div id="chart"></div>
    <div id="data"><b></b><h1><?php echo $data['nama']; ?>, Selamat Anda Mendapatkan..........</h1><b></div>
    <div id="submit">
        <input type="submit" name="submit" class="btn btn-success" value="submit"> 
    <!--<a style='font-size:20px;' href="submitaction.php?id=<?php echo $data['id'];?>" name="submit" class="btn btn-primary btn-xs">Submit</a></td>-->
    </div>  
    <div id="question">
        <h1></h1>

                <!--<input type="text" name='question' id="question" readonly="readonly">-->
            </div>
     <div>
                 <!--<label style="font-size: large;font-weight: bold;position: relative; ">Nomer Member</label> <br> -->
                <input style="text-align: center;" type="ba" name='ba' id="ba"  size="30"  value="<?php $question; ?>" >
            </div>  

   <div id="submit">
        <input type="submit" name="submit" class="btn btn-success" value="submit"> 
    
    </div>

JS



function spin(d){
            
            container.on("click", null);

            //all slices have been seen, all done
            console.log("OldPick: " + oldpick.length, "Data length: " + data.length);
            if(oldpick.length == data.length){
                console.log("done");
                container.on("click", null);
                return;
            }

            var  ps       = 360/data.length,
                 pieslice = Math.round(1440/data.length),
                 rng      = Math.floor((Math.random() * 1440) + 360);
                
            rotation = (Math.round(rng / ps) * ps);
            
            picked = Math.round(data.length - (rotation % 360)/ps);
            picked = picked >= data.length ? (picked % data.length) : picked;


            if(oldpick.indexOf(picked) !== -1){
                d3.select(this).call(spin);
                return;
            } else {
                oldpick.push(picked);
            }

            rotation += 90 - Math.round(ps/2);

            vis.transition()
                .duration(6000)
                .attrTween("transform", rotTween)
                .each("end", function(){

                    //mark question as seen
                    d3.select(".slice:nth-child(" + (picked + 1) + ") path")
                        .attr("fill", "#111");

                    //populate question
                    d3.select("#question h1")
                        .text(data[picked].question);

                    oldrotation = rotation;
                
                    container.on("click", spin);
                    document.getElementById("click").onclick = null;
                    
                });
        }

DATA Spin

 var data = [
{"label":"xa0xa0xa0xa0 xa0xa0xa0xa0 ?"+"xa0xa0xa0xa0xa0xa0xa0xa0xa0xa0",  "value":1,  "question":"A"}, // padding
{"label":"xa0xa0xa0xa0 xa0xa0xa0xa0 ?"+"xa0xa0xa0xa0xa0xa0xa0xa0xa0xa0",  "value":1,  "question":"B"}, // padding
{"label":"xa0xa0xa0xa0 xa0xa0xa0xa0 ?"+"xa0xa0xa0xa0xa0xa0xa0xa0xa0xa0",  "value":1,  "question":"C"}, // padding

FOrm Submit

<?php 
include 'koneksi.php';
error_reporting(0);
date_default_timezone_set('Asia/Jakarta');
$today= date("Y-m-d H:i:s");
if (isset($_POST['submit'])) {
 $question = $_GET['question'];    
 $id = trim(strip_tags($_POST['id']));
//  $coupon = trim(strip_tags($_POST['coupon'])); 
 $tlp = trim(strip_tags($_POST['tlp'])); 
 $nama = trim(strip_tags($_POST['nama'])); 
 $produk = $_POST['produk']; 
//  $store = trim(strip_tags($_POST['store'])); 
 $store =  $_POST['store'];
 $ba =  $_POST['ba'];
  print $ba;
  print $nama;
  print $question;
  

//  include "koneksi.php";    
 $selSto =mysqli_query($conn, "SELECT * FROM stock WHERE produk='$produk'");
 $sto    =mysqli_fetch_array($selSto);
 $stok    =$sto['qty'];
 //menghitung sisa stok
 $sisa    =$stok-1;
}


?>

.

I trial GET data to Form input, but can’t get data Spin.

My Expectation if spin stops, the user clicks SUBMIT data and Updates data to MYSQL

Multiplying prices of an item and when bought does not give the multiplied factor of that item

in the logic already tried updating the scorepersecond function and adding the actual factor to the item on the list but it wont give the correctly multiplied item. if i were to buy 5 cursors for 50 cash initially, it only gives 1 cursor and 1 passive money per second, same goes for any other item that are multiplied and bought at that multiplied price. html structure ids do correlate with the innerhtml. js code is shortened to only the functions handling the prices and updating the score per second, everything else is implemented

function updateScorePerSecond() {
    scorePerSecond = Math.round(cursors + (skibidiToilets * 10) + (josue * 100) + (nafisa * 250) + (andres * 500) + (sigma * 1000) + (hitler * 2500) + (qing * 5000) + (scott * 10000));
    document.getElementById("skibidiPerSecond").innerHTML = scorePerSecond.toLocaleString();
}

setInterval(function() {
    score += scorePerSecond;

    document.getElementById("score").innerHTML = score.toLocaleString();
    document.title = score + " skibidi - skibidi clicker";
}, 1000);

function multiplyPricesBy(factor) {
    const pricesToMultiply = ["cursorCost", "skibidiToiletCost", "josueCost", "nafisaCost", "andresCost", "sigmaCost", "hitlerCost", "qingCost", "scottCost"];
    const items = ["cursorCount", "skibidiToiletCount", "josueCount", "nafisaCount", "andresCount", "sigmaCount", "hitlerCount", "qingCount", "scottCount"];

    if (!factorApplied) {
        for (const priceId of pricesToMultiply) {
            window[priceId] *= factor;
            document.getElementById(priceId).innerHTML = window[priceId].toLocaleString();
        }
        
        let canAfford = true;
        for (const priceId of pricesToMultiply) {
            if (score < window[priceId]) {
                canAfford = false;
                break;
            }
        }
        if (canAfford) {
            for (const priceId of pricesToMultiply) {
                score -= window[priceId];
            }
            for (let i = 0; i < items.length; i++) {
                window[items[i]] += factor;
                document.getElementById(items[i]).innerHTML = window[items[i]].toLocaleString();
            }
            updateScorePerSecond();
        }
        
        factorApplied = true;
        document.querySelector('.buyAmountButtons').style.backgroundColor = "#90EE90";
        document.getElementById("score").innerHTML = score.toLocaleString();
    } else {
        for (const priceId of pricesToMultiply) {
            window[priceId] /= factor;
            window[priceId] = Math.round(window[priceId]);
            document.getElementById(priceId).innerHTML = window[priceId].toLocaleString();
        }

        factorApplied = false;
        document.querySelector('.buyAmountButtons').style.backgroundColor = "#DEDEDE";
    }

    document.getElementById("score").innerHTML = score.toLocaleString();
}




tried adding the factor to the items in the list and calling the function

problem in calling javascript function color(this)

why does on calling color(this) e.target value undefined and when i directly call the color function beside of mouseover then it work why?

const colors = [
        "#e74c3c",
        "#8e44ad",
        "#3498db",
        "#e67e22",
        "#2ecc71",
        "#f2e335",
        "#ef4a92",
      ];
      let randomcolor;
      let square_number = 300;
      let container = document.getElementById("container");
      let box;

      let interval;

      const color = (e) => {
        const random = randomcolors();
        console.log(random, e.target);

        e.target.style.backgroundColor = random;
      };
      for (let i = 0; i < square_number; i++) {
        box = document.createElement("div");
        box.classList.add("square");

        container.appendChild(box);
      }
      document.querySelectorAll(".square").forEach((square) => {
        square.addEventListener("mouseover", () => {
          color(this);
        });
      });

     

      // color-selection
      const randomcolors = () => {
        return colors[Math.floor(Math.random() * 7)];
      };

I am calling color(e) function but on callig color(e) function i get e.target value undefined but when i called color function beside mouseover ,color(e) function work explain me why this happened

Nestjs execute provider without providing it in module

I have a module which is exporting all sorts of auth related guards. And I had made a guard which can execute multiple guard inspired from this.

But whenever i try to execute, nestjs always gives me an error saying
ERROR [ExceptionsHandler] Nest could not find AdminGuard element (this provider does not exist in the current context).

How can i achive it without providing that guards in that module?

My sample code

AuthModule

@Module({
  imports: [PrismaModule],
  providers: [
    AuthService,
    DummyGuard,
    AdminGuard,
  ],
  controllers: [AuthController],
  exports: [DummyGuard, AdminGuard],
})
export class AuthModule {}

My another module which is using that AuthModule

@Module({
  imports: [PrismaModule, AuthModule],
  providers: [StatsService],
  controllers: [StatsController],
})
export class StatsModule {}

My controller in StatModule

@Controller('stats')
export class StatsController {
  constructor(private readonly statsService: StatsService) {}

  @MultipleGuardsReferences(AdminGuard, DummyGuard)
  @UseGuards(MultipleAuthorizeGuard)
  @Get('dummy')
  dummy() {
    return {
      ok: true,
    };
  }
}

Create new Stripe checkout link with new Firestore Entry

I am currently doing a fundraiser page and I am still struggling on how to make a new Stripe payment link with the creation of a new entry on Firestore database. How do I implement it, as I am kind of struggling with it? Thanks.

const stripe = require('stripe')('KEY_HERE');
const session = await stripe.checkout.sessions.create({
  success_url: 'https://example.com/success',
  line_items: [
    {
      price: 'PriceHere',
      quantity: 1,
    },
  ],
  mode: 'payment',
});

const addFundr = document.querySelector(".add");
addFundr.addEventListener("submit", (e) => {
  e.preventDefault();

  addDoc(collRef, {
    fundName: addFundr.fundName.value,
    fundAmount: addFundr.fundAmount.value,
    fundDesc: addFundr.fundDesc.value,
  }).then(() => {
    alert("Fundraiser created");
    window.location.href = "/fundraise/fundraise.html";
  });
});

How do I link to a pdf in React? [duplicate]

I’m trying to make it so that a user can click a button and in a different tab the pdf attachted to that button will show up. When I click the button it just opens the same page and the url has the path for the pdf, but still shows the original page. How can I get it to display the pdf? –I’m using window.open to open the pdf currently

const Profile = () => {
    return (
        <section id='profile'>
            <div className="section__pic-container">
                <img src={require("./assets/profile-picture2.png")} alt="Umar Manzoor profile Picture"/>
            </div>
            <div className="section__text">
                <p className="section__text__p1">Hello I'm</p>
                <h1 className="title">Umar Manzoor</h1>
                <p class="section__text__p2">Fullstack Developer</p>
                <div className="btn-container">
                    <button className="btn btn-color-2" onClick={() => window.open('./assets/Resume.pdf')}>
                        Download Resume
                    </button>
                </div>
            </div>
        </section>
    )
}

export default Profile

“type” keyword in mongoose schema

So I am new to Typescript but in the Mongoose library you can define a Schema like the following:

const blogSchema = new Schema({
  title: {type: String},
  author: {type: String}
})

What does “type” mean here?

Is {type: String} another object assigned to both title and author? Or is it some Typescript syntax?

I looked at Mongoose source code and found that String is a class, but I can’t understand what this would mean in the above code –> title: {type: String}

Converting map which uses Leaflet.js CRS.Simple to OpenLayers 8.x

I have a game map implemented in Leaflet.js with custom coordinate transformations for Grand Theft Auto V. I’m trying to convert this map from Leaflet.js into Open Layers 8.x due to some annoying limitations in Leaflet.js and the need for some of Open Layers features not easily available within Leaflet.js.

function createCRS() {
  return L.extend({}, L.CRS.Simple, {
    projection: L.Projection.LonLat,
    transformation: new L.Transformation(0.02072, 117.3, -0.0205, 172.8),
    scale: function (zoom) {
      return Math.pow(2, zoom);
    },
    zoom: function (scale) {
      return Math.log(scale) / 0.6931471805599453;
    },
    distance: function (pos1, pos2) {
      var x_difference = pos2.lng - pos1.lng;
      var y_difference = pos2.lat - pos1.lat;
      return Math.sqrt(x_difference * x_difference + y_difference * y_difference);
    },
    infinite: true
  })
}

var crs = createCRS();
var map = new L.Map('map', {
  center: [0, 0],
  zoom: 3,
  crs: crs,
  pmIgnore: false,
});

L.marker([0, 0], {}).addTo(map) // coordinate 0,0

// map layer boilerplate omitted for brevity

It’s worth noting that coordinate [0, 0] is not in the top left of the map, it’s actually towards the bottom left corner:

map marker 0,0

The Grand Theft Auto V map is 8192 x 8192px in size and I use map tiles (256 x 256px tiles) with up to 5 zoom levels. I’ve tried to use addCoordinateTransforms and a projection with the pixels unit, but have had no luck. Any markers I add to the map at coordinate [0, 0] always end up at the top-left corner of the map, which in turn means every other valid GTA 5 coordinate is also incorrectly placed (usually off the map).

You can see a reproduction of the incorrect [0, 0] coordinate at the following sandbox, complete with the coordinate plane image outlining where coordinate [0, 0] should be located. My ultimate goal is to do this in a way where I can apply any marker, polygon, etc. as a map layer using GTA V coordinates without having to transform the coordinates while inserting them. Instead, coordinates should be translated properly by whatever transformation layer exists within Open Layers.

Code Sandbox: https://codesandbox.io/p/sandbox/ol-gtavmap-gnkdmf

Usage of the Term ‘directive’ for Control Flow Statements

One article of a helpful JavaScript guide repeatedly refers to break and continue as ‘directives’, but I have only seen them referred to as ‘control flow statements’ before. What is the motivation for this terminology (particularly in JavaScript)?

My guess would be that it simply indicates that if we were to interpret the code into assembly, it would appear as a directive; I am wondering if there is any more meaning behind its usage, or if my guess is totally off base.