简体   繁体   中英

Best NodeJS Workflow for team development

I'm trying to implement NodeJS and Socket.io for real time communication between two devices (PC & Smartphones) in my company product.

Basically what I want to achieve is sending a notification to all online users when somebody change something on a file.

All the basic functionality for saving the updates are already there and so, when everything is stored and calculated, I send a POST request to my Node server saying that something changed and he need to notify the users.

The problem now is that when I want to change some code in the NodeJS scripts, as long as I work alone, I can just upload the new files via FTP and just restart the pm2 service, but when my colleagues will start working with me on this story we will have problems merging our changes without overlapping each other.

Launching a local server is also not possible because we need the connection between our current server and the node machine and since our server is online it cannot access our localhosts.

It's there a way for a team to work together in the same Node server but without overlapping each other ?

Implement changes using some other option rather than FTP. For example:

You can use webdav-fs in authenticated or non-authenticated mode:

// Using authentication: 
var wfs = require("webdav-fs")(
        "http://example.com/webdav/",
        "username",
        "password"
    );

wfs.readdir("/Work", function(err, contents) {
    if (!err) {
        console.log("Dir contents:", contents);
    } else {
        console.log("Error:", err.message);
    }
});

putFileContents(remotePath, format, data [, options]) Put some data in a remote file at remotePath from a Buffer or String. data is a Buffer or a String. options has a property called format which can be "binary" (default) or "text".

var fs = require("fs");

var imageData = fs.readFileSync("someImage.jpg");

client
    .putFileContents("/folder/myImage.jpg", imageData, { format: "binary" })
    .catch(function(err) {
        console.error(err);
    });

And use callbacks to notify your team, or lock the files via the callback.

References

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM