How to use @airbrake/node - 5 common examples

To help you get started, we’ve selected a few @airbrake/node examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github airbrake / airbrake-js / packages / node / examples / express / app.js View on Github external
async function main() {
  const airbrake = new Airbrake.Notifier({
    projectId: process.env.AIRBRAKE_PROJECT_ID,
    projectKey: process.env.AIRBRAKE_PROJECT_KEY,
  });

  console.log(pg.Client.prototype.query);

  const client = new pg.Client();
  await client.connect();

  const app = express();

  // This middleware should be added before any routes are defined.
  app.use(airbrakeExpress.makeMiddleware(airbrake));

  app.get('/', async function home(req, res) {
    const result = await client.query('SELECT $1::text as message', [
github airbrake / airbrake-js / packages / node / examples / express / app.js View on Github external
const result = await client.query('SELECT $1::text as message', [
      'Hello world!',
    ]);
    console.log(result.rows[0].message);

    res.send('Hello World!');
  });

  app.get('/hello/:name', function hello(req, res) {
    throw new Error('hello from Express');
    res.send(`Hello ${req.params.name}`);
  });

  // Error handler middleware should be the last one.
  // See http://expressjs.com/en/guide/error-handling.html
  app.use(airbrakeExpress.makeErrorHandler(airbrake));

  app.listen(3000, function() {
    console.log('Example app listening on port 3000!');
  });
}
github airbrake / airbrake-js / packages / node / examples / express / app.js View on Github external
async function main() {
  const airbrake = new Airbrake.Notifier({
    projectId: process.env.AIRBRAKE_PROJECT_ID,
    projectKey: process.env.AIRBRAKE_PROJECT_KEY,
  });

  console.log(pg.Client.prototype.query);

  const client = new pg.Client();
  await client.connect();

  const app = express();

  // This middleware should be added before any routes are defined.
  app.use(airbrakeExpress.makeMiddleware(airbrake));

  app.get('/', async function home(req, res) {
    const result = await client.query('SELECT $1::text as message', [
      'Hello world!',
    ]);
    console.log(result.rows[0].message);

    res.send('Hello World!');
  });

  app.get('/hello/:name', function hello(req, res) {
    throw new Error('hello from Express');
    res.send(`Hello ${req.params.name}`);
  });

  // Error handler middleware should be the last one.
github CitizensFoundation / active-citizen / utils / airbrake.js View on Github external
if(process.env.AIRBRAKE_PROJECT_ID) {
  const Airbrake = require('@airbrake/node');
  let airBrake = null;

  try {
    airBrake = new Airbrake.Notifier({
      projectId: process.env.AIRBRAKE_PROJECT_ID,
      projectKey: process.env.AIRBRAKE_API_KEY,
    });
  } catch (error) {
    airBrake = null;
    console.error(error);
  }

  module.exports = airBrake;
}
github airbrake / airbrake-js / packages / node / examples / nodejs / app.js View on Github external
.createServer(function(req, res) {
    if (req.url === '/favicon.ico') {
      res.writeHead(404);
      res.end();
      return;
    }

    res.writeHead(200, { 'Content-Type': 'text/plain' });
    res.end('Hello World\n');
    throw new Error('I am an uncaught exception');
  })
  .listen(8080);

console.log('Server running on port 8080.');

var airbrake = new Airbrake.Notifier({
  projectId: process.env.AIRBRAKE_PROJECT_ID,
  projectKey: process.env.AIRBRAKE_PROJECT_KEY,
});

@airbrake/node

Official Airbrake notifier for Node.js

MIT
Latest version published 2 years ago

Package Health Score

56 / 100
Full package analysis