@falconeye-tech/sdk

1.0.2 • Public • Published

FalconEye SDK for JavaScript

Content

  • Supported Platforms

  • Installation and Usage

Supported Platforms

  • Express

  • Javascript

Installation and Usage

Just simply install by npm

npm install --save @falcon-tech/node

Setup and usage of the SDK follows by the principle.

Initialization

import fe from '@falconeye-tech/sdk';

const er = new fe();

await er.init({
  apiHost: 'https://handsomelai.shop',
  userKey: '',
  clientToken: '',
});

If you initialize successfully, you will see the text on the terminal:

initialize SDK successfully
Listening on port 3001

Custom error logger in the try/catch

app.get('/programError', async (req, res, next) => {
  try {
    console.log('Hi');
    throw new Error('This is the error!');
  } catch (e) {
    er.captureError(e);
  }
});

Usage in express framework

app.use(er.requestHandler());

app.get('/typeError', async (req, res, next) => {
  try {
    console.logg('Hi');
  } catch (e) {
    next(e);
  }
});

// ... routes

app.use(er.errorHandler());

// Global error handler
app.use((err, req, res, next) => {
  res.status(error.statusCode).json({
    error: error.message,
  });
});

Package Sidebar

Install

npm i @falconeye-tech/sdk

Weekly Downloads

1

Version

1.0.2

License

ISC

Unpacked Size

5.4 kB

Total Files

4

Last publish

Collaborators

  • handsomelai