1.0.0 • Published 6 years ago
splunk_module_test v1.0.0
splunkConfig.json
A sample configuration file to setup the module
{
"index" : "democom",
"valid_domains" : [
"http://localhost:4000",
"https://www.google.com.pk",
"http://chaijs.com",
"https://developer.mozilla.org"
],
"token" : "51032512-b834-4c21-85e2-eda7616ea3a5",
"url" : "http://localhost:8088/services/collector"
}
splunkModule.js
The module can be used in two ways.
- The server can use it as a middleware, in which case the server will have to create routing in the server.
const app = express();
const splunkConfig = require('splunkConfig.json');
const splunkModule = require('splunkModule');
app.use(bodyParser.json());
var mySplunk = splunkModule.middleWare(splunkConfig);
// configuring the middleware with the endpoint
app.post('/track', mySplunk, (req, res) => {
res.json({
success: true,
message: 'Post Data Successfully!',
});
})
- The server can let the module handle the /track route and use the FullSetup by passing it the app object
const app = express();
const splunkConfig = require('splunkConfig.json');
const splunkModule = require('splunkModule');
splunkModule.fullSetup(splunkConfig, app);
1.0.0
6 years ago