Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8557385
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T15:33:47+00:00 2026-06-11T15:33:47+00:00

I just got my first app up and running on Node.js. As of now,

  • 0

I just got my first app up and running on Node.js. As of now, it is simply serving up a static file. But I have a few ideas that will be implemented down the road so I’m going ahead and getting Node setup so I’ll be ready for it when that time comes.

// get modules
var express = require('express');
var fs = require('fs');

// create app instance
var app = express();

// static files middleware
app.use("/assets", express.static(__dirname + '/assets'));

// main route
app.get('/', function(req, res) {
    var html = fs.readFileSync('assets/views/main.html', 'utf8');
    res.send(html);
});

// make web server listen on specific port
app.listen(8080);

NOTE: I realize I don’t need Express to serve one route, but I figured what’s the harm in getting a head start on that as well?! 🙂

The first idea i had is to make a way to let all users currently using the app that there has been an update and that they must refresh their browser. There is no need to save the current state of the app as it is pretty basic.

So, if I am a user, I’m using the app and boom, I get a pretty little modal-window-alert-notification thingy letting me know that I need to refresh.

Also, if some user loads the app AFTER I have sent the alert, that user should not see the alert at all (because they should already be seeing the new changes).

I have done some googling on the subject and I’m just not satisfied with the examples i found. I do not think I want to have to update a notifications.xml file (which node.js would be watching) to push a new notification.

One solution I can think of would be to make a command that can be executed from the command line that will (somehow) send a new notification to the app. Perhaps using something like Grunt.js (I’m not sure if it would be a good fit for this as I’ve never used it). Basically, once the notification has been sent, all traces of it should disappear. That’s why I think a command line approach would be good.

Here’s my question: How (generally speaking) should I implement something like this? I am a Node.js newbie but I am pretty comfortable with javascript and the command line.

Please feel free to offer up any alternative solution you think would be better for me (other than a command line approach), or any tools that you think could help me.

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T15:33:48+00:00Added an answer on June 11, 2026 at 3:33 pm

    If you want to push updates to a web client, one way is to use something like Socket.io. This creates a two-way pipe between client and server that you can use to asynchronously push updates through.

    Sample server:

    var app = require('express').createServer()
      , io = require('socket.io').listen(app);
    
    app.listen(80);
    
    app.get('/', function (req, res) {
      res.sendfile(__dirname + '/index.html');
    });
    
    io.sockets.on('connection', function (socket) {
      socket.emit('news', { hello: 'world' });
      socket.on('my other event', function (data) {
        console.log(data);
      });
    });
    

    Sample client:

    <script src="/socket.io/socket.io.js"></script>
    <script>
      var socket = io.connect('http://localhost');
      socket.on('news', function (data) {
        alert('New news has come in! Please refresh your page!');
        socket.emit('my other event', { my: 'data' });
      });
    </script>
    

    The other option is to poll from the client using Javascript to actively look for updates. You would need to keep some state on the server for each client that would determine if that client required an update. The client would then make a get request on some timer interval (once a second, for example) to a secondary route and the server would reply with ‘Yes, you need an update’ or ‘No, you don’t need an update’. If yes, the client Javascript would then pop up your modal box and tell the user to refresh.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've just got my first SQLite database up and running but to reproduce it
I have a Django app running django-piston for the first time. I've got a
I've just got my first VPS & have set up NGinx, Ruby, Rails &
I just got an email from twitter saying my keys have now been enabled
So I just got my first django app deployed. I did a syncdb and
Just going through the starting tutorials, and while I got the app running fine,
I just got my first app approved on the App Store (Woohoo!) and it
Hi I'm writing my first Java app and I've got a few Testcases (*.tc
We just got our first major Perl CGI assignment in my CS class. Our
I just got my first Android device, I love it... I also love the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.