darkspark-expressjs-plug

1.7.2 • Public • Published

Expressjs Plug for Darkspark

Download the Expressjs Plug

To download the Express Darkspark plug, use the following:

npm i darkspark-expressjs-plug

To download to a specific directory, follow the guide here. Otherwise, this will automatically download to the node-modules folder in your root directory.

Load the Module in your Application

Move the package to your Express project directory. In the source file in which your express instance is created, require the downloaded plug:

const {
  darkspark,
  darksparkVerify,
} = require("../location/of/darkspark_expressjs.js");

Call the Darkspark Function in your Application

The darkspark function should be called with your Express application as its first argument, and your Darkspark API key as its second argument. For example,

const app = express();
darkspark(app, "key_abcdef");

The darksparkVerify function should be included in the verify option on any body-parser middleware you have installed on your application. Depending on your setup, this may look like any of the following:

bodyParser.json({
  verify: darksparkVerify,
});
bodyParser.urlencoded({
  verify: darksparkVerify,
});
app.use(
  express.json({
    verify: darksparkVerify,
  })
);
app.use(
  express.urlencoded({
    extended: true,
    verify: darksparkVerify,
  })
);

This completes the setup. The next time you deploy your application, incoming API calls will be captured by Darkspark and populate the Darkspark dashboard.

Package Sidebar

Install

npm i darkspark-expressjs-plug

Homepage

darkspark.io

Weekly Downloads

1

Version

1.7.2

License

MIT

Unpacked Size

324 kB

Total Files

3

Last publish

Collaborators

  • contxt-ru
  • robbobby
  • neilgallcontxt
  • garydarnell