Skip to content

Commit 26abf05

Browse files
authored
Update/architecture legacy node (#969)
* condensed all integrations into one page. Updated links * fixed broken link * update snapshot * updated redirects
1 parent 208b952 commit 26abf05

File tree

10 files changed

+175
-178
lines changed

10 files changed

+175
-178
lines changed

__tests__/__snapshots__/documentation.js.snap

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -193,12 +193,7 @@ Array [
193193
"clients/node/coffeescript/index.html",
194194
"clients/node/config/index.html",
195195
"clients/node/index.html",
196-
"clients/node/integrations/connect/index.html",
197-
"clients/node/integrations/express/index.html",
198196
"clients/node/integrations/index.html",
199-
"clients/node/integrations/koa/index.html",
200-
"clients/node/integrations/loopback/index.html",
201-
"clients/node/integrations/sails/index.html",
202197
"clients/node/sourcemaps/index.html",
203198
"clients/node/typescript/index.html",
204199
"clients/node/usage/index.html",

nginx.conf

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,26 @@ server {
250250
location = /clients/ruby/integrations/rails/ {
251251
return 302 /clients/ruby/integrations/;
252252
}
253+
254+
location = /clients/node/integrations/connect/ {
255+
return 302 /clients/node/integrations/;
256+
}
257+
258+
location = /clients/node/integrations/express/ {
259+
return 302 /clients/node/integrations/;
260+
}
261+
262+
location = /clients/node/integrations/koa/ {
263+
return 302 /clients/node/integrations/;
264+
}
265+
266+
location = /clients/node/integrations/loopback/ {
267+
return 302 /clients/node/integrations/;
268+
}
269+
270+
location = /clients/node/integrations/sails/ {
271+
return 302 /clients/node/integrations/;
272+
}
253273

254274
location / {
255275
try_files $uri $uri.html $uri/ $uri/index.html =404;

src/collections/_documentation/clients/node/index.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -114,20 +114,20 @@ Raven and Sentry support [Source Maps](http://www.html5rocks.com/en/tutorials/de
114114

115115
## Middleware and Integrations
116116

117-
If you’re using Node.js with a web server framework/library like Connect, Express, or Koa, it is recommended to configure one of Raven’s server middleware integrations. See [_Integrations_]({%- link _documentation/clients/node/integrations/index.md -%}).
117+
If you’re using Node.js with a web server framework/library like Connect, Express, or Koa, it is recommended to configure one of Raven’s server middleware integrations. See [_Integrations_]({%- link _documentation/clients/node/integrations.md -%}).
118118

119119
## Deep Dive
120120

121121
For more detailed information about how to get most out of Raven there is additional documentation available that covers all the rest:
122122

123123
- [Configuration]({%- link _documentation/clients/node/config.md -%})
124124
- [Usage]({%- link _documentation/clients/node/usage.md -%})
125-
- [Integrations]({%- link _documentation/clients/node/integrations/index.md -%})
126-
- [Connect]({%- link _documentation/clients/node/integrations/connect.md -%})
127-
- [Express]({%- link _documentation/clients/node/integrations/express.md -%})
128-
- [Koa]({%- link _documentation/clients/node/integrations/koa.md -%})
129-
- [Loopback]({%- link _documentation/clients/node/integrations/loopback.md -%})
130-
- [Sails]({%- link _documentation/clients/node/integrations/sails.md -%})
125+
- [Integrations]({%- link _documentation/clients/node/integrations.md -%})
126+
- [Connect]({%- link _documentation/clients/node/integrations.md -%}#connect)
127+
- [Express]({%- link _documentation/clients/node/integrations.md -%}#express)
128+
- [Koa]({%- link _documentation/clients/node/integrations.md -%}#koa)
129+
- [Loopback]({%- link _documentation/clients/node/integrations.md -%}#loopback)
130+
- [Sails]({%- link _documentation/clients/node/integrations.md -%}#sails)
131131
- [Source Maps]({%- link _documentation/clients/node/sourcemaps.md -%})
132132
- [Source Maps]({%- link _documentation/clients/node/typescript.md -%})
133133
- [CoffeeScript]({%- link _documentation/clients/node/coffeescript.md -%})
Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
---
2+
title: Integrations
3+
---
4+
5+
## Connect
6+
7+
<!-- WIZARD -->
8+
```javascript
9+
var connect = require('connect');
10+
var Raven = require('raven');
11+
12+
// Must configure Raven before doing anything else with it
13+
Raven.config('___PUBLIC_DSN___').install();
14+
15+
function mainHandler(req, res) {
16+
throw new Error('Broke!');
17+
}
18+
19+
function onError(err, req, res, next) {
20+
// The error id is attached to `res.sentry` to be returned
21+
// and optionally displayed to the user for support.
22+
res.statusCode = 500;
23+
res.end(res.sentry + '\n');
24+
}
25+
26+
connect(
27+
// The request handler be the first item
28+
Raven.requestHandler(),
29+
30+
connect.bodyParser(),
31+
connect.cookieParser(),
32+
mainHandler,
33+
34+
// The error handler must be before any other error middleware
35+
Raven.errorHandler(),
36+
37+
// Optional fallthrough error handler
38+
onError,
39+
).listen(3000);
40+
```
41+
<!-- ENDWIZARD -->
42+
43+
## Express
44+
45+
<!-- WIZARD -->
46+
```javascript
47+
var app = require('express')();
48+
var Raven = require('raven');
49+
50+
// Must configure Raven before doing anything else with it
51+
Raven.config('__DSN__').install();
52+
53+
// The request handler must be the first middleware on the app
54+
app.use(Raven.requestHandler());
55+
56+
app.get('/', function mainHandler(req, res) {
57+
throw new Error('Broke!');
58+
});
59+
60+
// The error handler must be before any other error middleware
61+
app.use(Raven.errorHandler());
62+
63+
// Optional fallthrough error handler
64+
app.use(function onError(err, req, res, next) {
65+
// The error id is attached to `res.sentry` to be returned
66+
// and optionally displayed to the user for support.
67+
res.statusCode = 500;
68+
res.end(res.sentry + '\n');
69+
});
70+
71+
app.listen(3000);
72+
```
73+
<!-- ENDWIZARD -->
74+
75+
## Koa
76+
77+
<!-- WIZARD -->
78+
```javascript
79+
var koa = require('koa');
80+
var Raven = require('raven');
81+
82+
var app = koa();
83+
Raven.config('___PUBLIC_DSN___').install();
84+
85+
app.on('error', function (err) {
86+
Raven.captureException(err, function (err, eventId) {
87+
console.log('Reported error ' + eventId);
88+
});
89+
});
90+
91+
app.listen(3000);
92+
```
93+
<!-- ENDWIZARD -->
94+
95+
## Loopback
96+
97+
If you’re using Loopback 2.x LTS, make sure you’ve migrated to [strong-error-handler](https://loopback.io/doc/en/lb2/Using-strong-error-handler.html), otherwise no errors will get to `raven-node`.
98+
99+
Configure `raven-node` as early as possible:
100+
101+
```javascript
102+
// server/server.js
103+
104+
const Raven = require('raven');
105+
Raven.config('__DSN__').install();
106+
```
107+
108+
Add `Raven.errorHandler` as a Loopback middleware:
109+
110+
```json
111+
// server/middleware.json
112+
113+
"final:after": {
114+
"raven#errorHandler": {},
115+
"strong-error-handler": {
116+
"debug": false,
117+
"log": false
118+
}
119+
}
120+
```
121+
122+
## Sails
123+
124+
```javascript
125+
// config/http.js
126+
127+
var Raven = require('raven');
128+
Raven.config('__DSN__').install();
129+
130+
module.exports.http = {
131+
middleware: {
132+
// Raven's handlers has to be added as a keys to http.middleware config object
133+
requestHandler: Raven.requestHandler(),
134+
errorHandler: Raven.errorHandler(),
135+
136+
// And they have to be added in a correct order to middlewares list
137+
order: [
138+
// The request handler must be the very first one
139+
'requestHandler',
140+
// ...more middlewares
141+
'router',
142+
// The error handler must be after router, but before any other error middleware
143+
'errorHandler',
144+
/// ...remaining middlewares
145+
]
146+
}
147+
}
148+
```

src/collections/_documentation/clients/node/integrations/connect.md

Lines changed: 0 additions & 40 deletions
This file was deleted.

src/collections/_documentation/clients/node/integrations/express.md

Lines changed: 0 additions & 34 deletions
This file was deleted.

src/collections/_documentation/clients/node/integrations/index.md

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/collections/_documentation/clients/node/integrations/koa.md

Lines changed: 0 additions & 22 deletions
This file was deleted.

src/collections/_documentation/clients/node/integrations/loopback.md

Lines changed: 0 additions & 31 deletions
This file was deleted.

src/collections/_documentation/clients/node/integrations/sails.md

Lines changed: 0 additions & 30 deletions
This file was deleted.

0 commit comments

Comments
 (0)