Where can i get the API-key for Kitsu?

I want to use Kitsu API for a small web project and I don’t know where to get the api key. Pls help. Thanks

I read the documentation and searched all over it and still no clue where to get it. Maybe I miss it or not. I also created a Kitsu account because I saw a post that I need to in order to get the api but I still can’t find it.

add some validation in odoo 17 point_of_sale set_discount function in file models.js

in odoo 17 pos, there is a function named set_discount
in models.js file , i want to add extra validation in it like this :

set_discount(discount) {
    var parsed_discount =
        typeof discount === "number"
            ? discount
            : isNaN(parseFloat(discount))
            ? 0
            : oParseFloat("" + discount);
    var disc = Math.min(Math.max(parsed_discount || 0, 0), 100);this.product.id });
    
    //here i want to get max discount from product.product
    
    //var maxDiscount = this.product.maxDiscount;
    //if(disc > maxDiscount){
        //alert("discount > max discount");
        //return;
    //}

    this.discount = disc;
    this.discountStr = "" + disc;
}

how can i do this (var maxDiscount = this.product.maxDiscount;)
in odoo 17 js

add some validation in odoo 17 point_of_sale set_discount function in file models.js

in odoo 17 pos, there is a function named set_discount
in models.js file , i want to add extra validation in it like this :

set_discount(discount) {
    var parsed_discount =
        typeof discount === "number"
            ? discount
            : isNaN(parseFloat(discount))
            ? 0
            : oParseFloat("" + discount);
    var disc = Math.min(Math.max(parsed_discount || 0, 0), 100);this.product.id });
    
    //here i want to get max discount from product.product
    
    //var maxDiscount = this.product.maxDiscount;
    //if(disc > maxDiscount){
        //alert("discount > max discount");
        //return;
    //}

    this.discount = disc;
    this.discountStr = "" + disc;
}

how can i do this (var maxDiscount = this.product.maxDiscount;)
in odoo 17 js

The requested module ‘../node_modules/generate-serial-number/test/index.js’ does not provide an export named ‘generate’

Hi I was trying to make an object with all details that a ticket have for that I used generate-serial-number module to generate a number for ticket earlier I was using

const genrator = require(generate-serial-number);

this was working fine in the console but when I tried to add that to an object in html the browser showed an error

movies.js:1 Uncaught ReferenceError: require is not defined

I searched online they recommend to use import instead of require()

but the error changed to

The requested module ‘../node_modules/generate-serial-number/test/index.js’ does not provide an export named ‘generate’

Here’s the code before adding import

var generator = require("generate-serial-number");

const seatNumberGenerator = () => {
  const alphabet = "abcdefghijklmnopqrstuvwxyz";
  const randomLetter = alphabet[Math.floor(Math.random() * alphabet.length)];
  return `${Math.floor(Math.random() * 100)}${randomLetter}`;
};

const showTimmings = (date, time) => {
  show = new Date(2023, 11, date, time, 0, 0, 0);
  return {
    showDate: `${show.getDate()}/${show.getMonth() + 1}`,
    showTime: `${show.getHours()}:00`,
  };
};

const Movies = [
  {
    name: "Animal",
    ticketPrice: 300,
    image: "../assets/images/animal-indian-movie-poster.jpg",
    rating: 3.9,
    genre: "Action/Crime",
    time: "3h 22m",
    seatNumber: seatNumberGenerator(),
    show: showTimmings(3, 1),
    ticketNumber: generator.generate(6),
  },
  {
    name: "Fukrey 3",
    ticketPrice: 300,
    rating: 2.9,
    genre: "Comedy/Thriller",
    time: "2h 27m",
    image: "../assets/images/fukrey-3-indian-movie-poster.jpg",
    seatNumber: seatNumberGenerator(),
    show: showTimmings(3, 16),
    ticketNumber: generator.generate(6),
  },
  {
    name: "Tiger 3",
    ticketPrice: 300,
    image: "../assets/images/tiger-3-indian-movie-poster.jpg",
    rating: 3.5,
    genre: "Action/Thriller",
    time: "2h 30m",
    seatNumber: seatNumberGenerator(),
    show: showTimmings(3, 20),
    ticketNumber: generator.generate(6),
  },
  {
    name: "Pathaan",
    ticketPrice: 300,
    image: "../assets/images/pathaan-indian-movie-poster.jpg",
    rating: 3.9,
    genre: "Action/Thriller",
    time: "2h 26m",
    seatNumber: seatNumberGenerator(),
    show: showTimmings(3, 23),
    ticketNumber: generator.generate(6),
  },
  {
    name: "Sam Bahadur",
    ticketPrice: 300,
    rating: 4.6,
    genre: "War/Drama",
    time: "2h 25m",
    image: "../assets/images/sam-bahadur-movie-poster.jpg",
    seatNumber: seatNumberGenerator(),
    show: showTimmings(3, 10),
    ticketNumber: generator.generate(6),
  },
];

export default Movies;

I tried changing it to import and even tried to check requirejs but that didn’t work maybe i messsed up a little while implementing requirejs

How to implement server side event in distributed environment?

I have two node js server which replicated code for the load balancing there is one Rabbitmq cluster which is commonly used in the project,rabbit mq message consumtion according to the roundrobin manner in the both servers, so messages consume by any one of the server whenever new messages comes in,

Now problem is that I have implemented the SSE (server side event) into the both servers if one user logged in or connect through SSE to anyone of the server and new message comes into the rabbitmq the SSE is called at that time to increse the count, but if user 1 connected to server 1 how server two will update the same total?

example -

server 1 => rabbitmq
server 2 => rabbitmq 

(same rabbitmq used by both server only one rabbitmq)

user 1 => server 1 (connected though the SSE) => rabbitmq 

now 

messages comes => rabbitmq gives message to server 2 

no user connected to server 2

message consumed by server 2 => incresing the count

but server 2 dont have any user which is need to update

i tryied multiple things but not worked any suggestions happy to take it

Message comes in the rabbit mq

rabbit mq send the messge to any one server

that one server need to update the count for all the server

or atleast send any trigger that he had recevied new message and update the count of that user

Twilio webhook – 403, invalid signature – node/express

I’ve been trying to validate a twilio webhok & spent nearly a full day trying to make this work. I’ve tested in both ngrok + my digital ocean app platform with the correct webhook url/twilio auth and no matter what i’m getting a 403 Forbidden

I’ve also tried the webhook() and get the same result,

Is there anything obvious that I’m doing wrong? I was trying to hesitate to post this, but i’m at my wits end with it.

The webhook is for call tracking, the endpoint itself is complete in everything but the validation, i’m creating a table row based off the incoming call

app.use(bodyParser.urlencoded({ extended: false }));

router.post('/', async (req, res) => {
  const twilioAuthToken = process.env.TWILIO_AUTH_TOKEN;
  const twilioWebhookUrl = process.env.TWILIO_WEBHOOK_URL;

  // Validate the request
  if (twilio.validateRequest(twilioAuthToken, req.headers['x-twilio-signature'], twilioWebhookUrl, req.body)) {

  } else {
    console.log('Invalid Twilio Signature');
    return res.status(403).send('Invalid Twilio Signature');
  }

}
  • Tried in both production and locally
  • Tried multiple auth tokens

Can API calls for MusicKit js be done in the front end?

I created my first web application with a front end and back end. I store my client secret and private keys as well as the process for the authorization and developer token generation in the backend.

I’ve read that exposing the developer token or refresh token in the front end is not best practice as its a security concern. Using developer tools, I noticed that the refresh token and developer token is able to be seen in my app when I make calls to endpoints. Due to this, I was wondering, is it necessary for ALL my API calls to be done in the backend as to not expose any credentials?

I am new to web development, so any guidance is well appreciated. Thank you.

Initially did everything in the front end. Learned about the importance in keeping credentials secure. Moved authorization and private credentials to backend. I’ve been using musicKit and it’s built in functions to make API calls in the front end, but noticed developer token is viewable and wanted to consult to see if a change is needed.

Why is my foreach loop not performing as intended?

I am trying to ensure that if dm[0] is already in siteNames array, that it does not get pushed to siteNames. Ie a unique array of values. For some reason, every value is being pushed to the array even if they are identical.

  const data = ref.current[0].getData()
data.forEach(function(d) { 
   const dm = d.filter(n => n)
   console.log(dm[0])
   if (!siteNames.includes(dm[0])){
    siteNames.push({name: dm[0], id: siteId})
    siteId += 1
   }
   console.log(siteNames)
 })

string.match returning empty strings when using ?=

I’m trying to find groups that may start inside another match with regex (eg: find ‘two’ and ‘one’ in ‘twone’)

So far the regex that could get to work at regex101.com is /(?=(one|two))/gm.
The problem is that when I try to use this pattern in javascript it returns two empty arrays. What am I doing wrong?

Qwik event that triggers when the element is initialized

I want to get an element. The quickest way to do that seems to be through event.target. So I want an event that is triggered as soon as an element is initialized, and then never again

Something like this

<div
onInit$={(e)=>{
  // do stuff with e.target
}}></div>

I’ve tried onLoad$ and onComplete$, niether of which did what you would expect them to.
Also onDomContentLoaded isnt a thing

How can I allow a particular username and PC name to use code?

I have a link google sheet
https://docs.google.com/spreadsheets/d/1_ar_zOx7NaQiMdNoOGmXNCdBcxwKQPZRCrzOKfv0rLc/edit#gid=865103119
the problem is many usernames can access and click on the button that makes the data conflicted. although I used the share function in Google sheet to limit account access but they can use one username to log on to other PCs.

I want to add some codes to control this. This means if the username and PC name match vs the username and PC name that was declared before then the code will activate otherwise don’t do anything but I don’t know about codes
Could you please resolve this to help me?

How to get YouTube channel ID from video or channel page using JavaScript?

window?.ytInitialPlayerResponse?.videoDetails?.channelId worked recently, but now ytInitialPlayerResponse is undefined. So how can I get the YouTube channel ID from a video or channel page using JavaScript? This is for a Firefox bookmarklet.

This is not a dupe of How can I get a channel ID from YouTube?. This question is specific to JavaScript, and to the two types of pages mentioned above, and none of the JavaScript-based answers work anymore.

Add noindex but follow on certain links

I have been searching online on how to deal with pagination duplication reported by search engines but i haven’t found a solution. The only thing that helps is to use a robots.txt but i can’t disallow every root paginated because of indexing.

My site has

example.com/page/1
example.com/category/page/1
example.com/author/page/1

I would like to place a wp function onto these pages, that will

noindex, follow
```.

If it's possible, then i will appreciate every effort!