nails-boilerplate 0.12.3 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
const Controller =
|
|
2
|
+
require("../../../../../index.js").Controller;
|
|
3
|
+
class ErrorController extends Controller {
|
|
4
|
+
// DO NOT OVERRIDE CONSTRUCTOR
|
|
5
|
+
index(params, request, response) {
|
|
6
|
+
response.json({
|
|
7
|
+
classbased_index: true
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
fivehundred(params, request, response) {
|
|
12
|
+
objectThatIsUndefined.attempt_to_access_field_erroneously();
|
|
13
|
+
return {value: "will never get here"};
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
testaction(params, request, response) {
|
|
17
|
+
response.json({
|
|
18
|
+
classbased_testaction: true
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async testpromise(params, request, response) {
|
|
23
|
+
response.json({
|
|
24
|
+
classbased_testpromise: true
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
module.exports = ErrorController;
|
|
@@ -32,6 +32,7 @@ var routes = [
|
|
|
32
32
|
['get', /^\/(\w+)\/(\w+)$/i, {0: 'controller', 1: 'action'}],
|
|
33
33
|
// Maps the first two parts of the path to controller and action, and the third to the id parameter
|
|
34
34
|
['get', "/:controller/:action/:id"],
|
|
35
|
+
['get', "/error/fivehundred", {json: true}],
|
|
35
36
|
|
|
36
37
|
['ws', "/", {controller: 'websocket'}],
|
|
37
38
|
['ws', "/voodoo", {controller: 'websocket', action: 'voodoo'}]
|
|
@@ -77,6 +77,33 @@ describe("Integration", function() {
|
|
|
77
77
|
})
|
|
78
78
|
});
|
|
79
79
|
|
|
80
|
+
describe("GET /error/fivehundred", function() {
|
|
81
|
+
it('should log the stack trace', function(done) {
|
|
82
|
+
chai.request(express_app)
|
|
83
|
+
.get('/error/fivehundred/500')
|
|
84
|
+
.end((err, res) => {
|
|
85
|
+
res.should.have.status(500);
|
|
86
|
+
//console.log(res.text);
|
|
87
|
+
//console.log(res);
|
|
88
|
+
//console.log(err);
|
|
89
|
+
done();
|
|
90
|
+
})
|
|
91
|
+
});
|
|
92
|
+
it('should return meaningful JSON', function(done) {
|
|
93
|
+
chai.request(express_app)
|
|
94
|
+
.get('/error/fivehundred')
|
|
95
|
+
.end((err, res) => {
|
|
96
|
+
res.should.have.status(500);
|
|
97
|
+
console.log("ZZZZZZZZZZ");
|
|
98
|
+
console.log(res.text);
|
|
99
|
+
//console.log(res.text);
|
|
100
|
+
//console.log(res);
|
|
101
|
+
//console.log(err);
|
|
102
|
+
done();
|
|
103
|
+
})
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
|
|
80
107
|
describe("WebSockets", function() {
|
|
81
108
|
it("should listen on /", function(done) {
|
|
82
109
|
this.timeout(2000);
|
|
@@ -25,7 +25,7 @@ var routes = [
|
|
|
25
25
|
// A test route which routes the first part of pathname to controller and the second to the action
|
|
26
26
|
['get', /^\/(\w+)\/(\w+)$/i, {0: 'controller', 1: 'action'}],
|
|
27
27
|
// Maps the first two parts of the path to controller and action, and the third to the id parameter
|
|
28
|
-
['get', "/:controller/:action/:id"]
|
|
28
|
+
['get', "/:controller/:action/:id"],
|
|
29
29
|
|
|
30
30
|
// Defines a WebSocket handler
|
|
31
31
|
['ws', "/:controller/:action/:id"]
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// Initializes application before server starts
|
|
2
2
|
// Each of these is REQUIRED
|
|
3
|
-
|
|
4
|
-
var
|
|
3
|
+
const path = require('path');
|
|
4
|
+
var SERVER_ROOT = path.resolve(__dirname, '/..');
|
|
5
|
+
var APP_ROOT = path.resolve(SERVER_ROOT, '/app');
|
|
5
6
|
|
|
6
7
|
// Only for reading the certificates for SSL
|
|
7
8
|
const fs = require('fs');
|