码迷,mamicode.com
首页 > 移动开发 > 详细

[Express + Webstrom] Debug Node.js RESTful application

时间:2014-12-10 07:05:49      阅读:244      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   io   ar   color   os   sp   for   

Using WebStrom can easily debug the Node applcation.

For example, we have an Node+Express application.

server.js:

/**
 * Created by Answer1215 on 12/9/2014.
 */
‘use strict‘;

var expres = require(‘express‘);
var app = expres();

app.get(‘/‘, function(request, response) {
    response.send(200, "Hello world");
});

app.listen(3000);

All it does just send back an "Hello World" string.

 

What we want is to see how to use webstrom to debug this server.js and get "Hello World" string from the console.

bubuko.com,布布扣

 

It will show:

bubuko.com,布布扣

 

Then in the Tools bar, select RESTful Client:

bubuko.com,布布扣

 

Set the HTTP method, Host/port, and Path, then click run, you will get "Hello world".

bubuko.com,布布扣

 

Notice that, if you modify the server.js, you should rerun the debug to get the lastest modification.

For example: We add a people path.

/**
 * Created by Answer1215 on 12/9/2014.
 */
‘use strict‘;

var expres = require(‘express‘);
var app = expres();

app.get(‘/‘, function(request, response) {
    response.send(200, "Hello world");
});

app.get(‘/people‘, function(request, response){

    response.json(200, "People yled");
});

app.listen(3000);

 

After rerun the debug, In RESTful client, we get:

bubuko.com,布布扣

[Express + Webstrom] Debug Node.js RESTful application

标签:style   blog   http   io   ar   color   os   sp   for   

原文地址:http://www.cnblogs.com/Answer1215/p/4154574.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!