#I'm having an issue deploying a nodejs app to docker or any other way.

3 messages · Page 1 of 1 (latest)

tacit birch
#

I have a nodejs app im building and i've attempted to deploy it a buncha ways to no avail. I currently have it dockerized but when i run it, it hangs when it starts index.js. This is what the code looks like

require('dotenv').config();
const currentDivision = require('./currentdivision');

// Replace the placeholders with your own Twitter API keys
const T = new Twit({
    consumer_key:         process.env.CONSUMER_KEY,
    consumer_secret:      process.env.CONSUMER_SECRET,
    access_token:         process.env.ACCESS_TOKEN,
    access_token_secret:  process.env.ACCESS_TOKEN_SECRET
});
  
  let previousDivision = currentDivision;
  
  setInterval(() => {
    if (previousDivision !== currentDivision) {
        // Check if the user has tweeted in the last hour
        T.get('statuses/user_timeline', { count: 1 }, function (err, data, response) {
            if (!err && data.length > 0) {
                let lastTweetTime = new Date(data[0].created_at);
                let currentTime = new Date();
                let timeDiff = currentTime - lastTweetTime;
                let minutesDiff = Math.floor(timeDiff / 60000);

                // If the user has tweeted in the last hour, delete the last tweet
                if (minutesDiff < 60) {
                    T.post('statuses/destroy/:id', { id: data[0].id_str }, function (err, data, response) {
                        console.log(`Deleted tweet: ${data.text}`);
                    });
                }

                // Send the new tweet
                T.post('statuses/update', { status: `The current division is: ${currentDivision}` }, function (err, data, response) {
                    console.log(`Sent tweet: ${data.text}`);
                });
                previousDivision = currentDivision;
            } else {
                console.log(err);
            }
        });
    }
}, 60000); // This will run the code every minute (60000 milliseconds)```

Help please! lol
torn bridge
#

does it run normally outside of docker etc?
node index.js

tacit birch
#

yeah but parts of it dont im figuring out how to troubleshoot it now