This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 254424

Summary: Code templates for Node.js
Product: javascript Reporter: Geertjan Wielenga <geertjan>
Component: Node.jsAssignee: Petr Pisl <ppisl>
Status: RESOLVED FIXED    
Severity: normal CC: anebuzelsky, tmysik
Priority: P2    
Version: 8.1   
Hardware: PC   
OS: Windows 7   
Issue Type: ENHANCEMENT Exception Reporter:

Description Geertjan Wielenga 2015-08-17 10:27:59 UTC
Create some simple code templates for Node.js. For example, when I type 'nodehttp' in the JavaScript editor and press Tab, I'd like to see this:

var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello World\n');
}).listen(1337, '127.0.0.1');
console.log('Server running at http://127.0.0.1:1337/');

When I type 'nodenet', in the JS editor, and press Tab, I'd like to see this:

var net = require('net');

var server = net.createServer(function (socket) {
  socket.write('Echo server\r\n');
  socket.pipe(socket);
});

server.listen(1337, '127.0.0.1');
Comment 1 Antonin Nebuzelsky 2015-08-20 15:42:10 UTC
For these code snippets it seems to me that they would be useful rather as sample projects.

IMO if we want to have code templates for Node.js apps, we should have a comprehensive list of most frequently used boiler plate code.
Comment 2 Petr Pisl 2015-08-24 08:44:29 UTC
I agree with Tonda. On the other hand I have created the files needed to add the templates to the editor. Requested templates were added as samples.