@transcend-io/typescript-webhook-example
Version:
Example of a webhook that can be integrated with Transcend.
54 lines • 2.17 kB
JavaScript
/**
* Developer note: this server is live at https://transcend-example.onrender.com.
* This server is used on the E-Shop-It Transcend instance https://e-shop-it.trsnd.co.
* Some endpoints are also used for other Transcend testing applications
*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
// Load webhook handling middlewares
const handleEnrichmentWebhook_1 = __importDefault(require("./handleEnrichmentWebhook"));
const handleDSRWebhook_1 = __importDefault(require("./handleDSRWebhook"));
const handleDSRWebhookPaginated_1 = __importDefault(require("./handleDSRWebhookPaginated"));
const handleHelloWorld_1 = __importDefault(require("./handleHelloWorld"));
// Constants
const constants_1 = require("./constants");
const logger_1 = require("./logger");
const morgan = require('morgan');
const express = require('express');
require('dotenv').config();
// Set up the server
const app = express();
const port = constants_1.PORT;
app.all('/health', (req, res) => res.sendStatus(200));
// Middlewares
app.use(morgan('tiny'));
app.use(express.urlencoded({
extended: false,
}));
app.use(express.json());
/**
* Receive webhook for identity enrichment (optional)
* This path is set by you in the Admin Dashboard.
*/
app.post('/transcend/enrichment', handleEnrichmentWebhook_1.default);
/**
* Make the root GET route return a message as a health check.
*/
app.get('/', handleHelloWorld_1.default);
/**
* Receive webhook (Transcend's notification to this server)
* This path is set by you in the Admin Dashboard.
*/
app.post('/transcend/new-dsr', handleDSRWebhook_1.default);
/**
* This route is an alternative to `/transcend/new-dsr` for situations
* where you have a lot of data of a certain type that you may need to
* page over and upload in chunks.
*/
app.post('/transcend/new-dsr-paginated', handleDSRWebhookPaginated_1.default);
app.listen(port, () => logger_1.logger.info(`Example custom data silo listening on port ${port}.`));
//# sourceMappingURL=app.js.map
;