UNPKG

@textback/notification-widget

Version:

TODO: Give a short introduction of your project. Let this section explain the objectives or the motivation behind this project.

225 lines (207 loc) 7.86 kB
'use strict'; const express = require('express'); const app = express(); const port = process.env.PORT || 3000; app.use(express.static('.')); app.get('/examples', (req, res) => { const query = Object.assign({ //widgetPath: 'https://cdn.jsdelivr.net/npm/@textback/notification-widget/build/index.js', widgetPath: 'http://localhost:8080/build/index.js', apiPath: 'https://my.dev.textback.io/api', widgetId: '7f4e72a9-6f97-b658-9496-016eeb97d0e4', lang: 'ru', data: JSON.stringify({orderId: 'insecureOrderID'}) }, req.query); let widgetCode = `<script src='${query.widgetPath}'></script>`; widgetCode += `\n<tb-notification-widget`; widgetCode += `\n widget-id='${query.widgetId}'`; if (query.apiPath) { widgetCode += `\n api-path='${query.apiPath}'`; } if (query.lang) { widgetCode += `\n lang='${query.lang}'`; } if (query.data) { widgetCode += `\n data='${query.data}'`; } widgetCode += `>\n</tb-notification-widget>`; res.render('examples.ejs', { query, widgetCode }); }); app.get('/api/endUserNotifications/widgets/error500', (req, res) => { res.sendStatus(500); }); app.get('/api/endUserNotifications/widgets/error404', (req, res) => { res.sendStatus(404); }); app.get('/api/endUserNotifications/widgets/a', (req, res) => { res.json({ '$error': null, '$items': null, '$value': { 'id': 'd43a36de-9659-45b5-9373-aed1a6d58dc5', 'vkApiId': null, 'accountId': '99bffda5-5bd1-49b1-b4f2-658854797c01', 'channels': [{ 'channel': 'tg', 'id': 'rb_dev_3_bot', 'slug': '@rb_dev_3_bot', 'enabled': true, 'channelId': null }, { 'channel': 'vk', //'type': 'apiCall', 'id': '124981888', 'slug': 'tb_test_group', 'enabled': true, 'channelId': 29 }, { 'channel': 'facebook', 'id': '323049074708312', 'slug': 'TA0ETXSdhM8JnvkB1iUM', 'enabled': true, 'channelId': null }, {'channel': 'viber', 'id': 'dev_', 'slug': '', 'enabled': true, 'channelId': null}], 'welcomeMessage': { 'text': null, 'markup': 'PLAIN', 'attachments': null, 'buttons': [{ 'type': 'HyperLinkButton', 'text': 'Читать статью', 'link': 'https://blog.textback.ru/notifications_in_messengers' }] }, 'title': {'value': 'test heading'}, 'description': {'value': 'test desc\r\nline'}, 'markUp': { 'body': {}, 'icon': {'type': 'preset'}, 'header': {'value': 'привет это тестовый заголовок чтобы понять какое нормальное число знак'}, 'description': {'value': 'это тестовый заголовок чтобы понять какое нормальное число знаков может быть в описании чтобы было читабельно и красиво и вообще нормально. это очень длинное название, прямо очень длинное очень приоче'}, 'title': {'value': 'asdadad'} }, 'displayOptions': {}, //'displayMode': 'popup' }, '$count': 1 }); }); app.get('/api/endUserNotifications/widgets/b', (req, res) => { res.json({ '$error': null, '$items': null, '$value': { 'id': 'd43a36de-9659-45b5-9373-aed1a6d58dc5', 'vkApiId': 5930339, 'accountId': '99bffda5-5bd1-49b1-b4f2-658854797c01', 'channels': [{ 'channel': 'tg', 'id': 'rb_dev_3_bot', 'slug': '@rb_dev_3_bot', 'enabled': true, 'channelId': null }, { 'channel': 'vk', 'type': 'apiCall', 'id': '124981888', 'slug': 'tb_test_group', 'enabled': true, 'channelId': 29 }, { 'channel': 'facebook', 'id': '323049074708312', 'slug': 'TA0ETXSdhM8JnvkB1iUM', 'enabled': true, 'channelId': null }, {'channel': 'viber', 'id': 'dev_', 'slug': '', 'enabled': true, 'channelId': null}], 'welcomeMessage': { 'text': null, 'markup': 'PLAIN', 'attachments': null, 'buttons': [{ 'type': 'HyperLinkButton', 'text': 'Читать статью', 'link': 'https://blog.textback.ru/notifications_in_messengers' }] }, 'title': {'value': 'test heading'}, 'description': {'value': 'test desc\r\nline'}, 'markUp': { 'body': {}, 'icon': {'type': 'preset'}, 'header': {'value': 'привет это тестовый заголовок чтобы понять какое нормальное число знак'}, 'description': {'value': 'это тестовый заголовок чтобы понять какое нормальное число знаков может быть в описании чтобы было читабельно и красиво и вообще нормально. это очень длинное название, прямо очень длинное очень приоче'}, 'title': {'value': 'asdadad'} }, 'displayOptions': {}, //'displayMode': 'popup' }, '$count': 1 }); }); app.get('/api/endUserNotifications/widgets/c', (req, res) => { res.json({ '$error': null, '$items': null, '$value': { 'id': 'd43a36de-9659-45b5-9373-aed1a6d58dc5', 'vkApiId': 5930339, 'accountId': '99bffda5-5bd1-49b1-b4f2-658854797c01', 'channels': [{ 'channel': 'tg', 'id': 'rb_dev_3_bot', 'slug': '@rb_dev_3_bot', 'enabled': true, 'channelId': null }, { 'channel': 'vk', 'id': '124981888', 'slug': 'tb_test_group', 'enabled': true, 'channelId': 29 }, { 'channel': 'facebook', 'id': '323049074708312', 'slug': 'TA0ETXSdhM8JnvkB1iUM', 'enabled': true, 'channelId': null }, {'channel': 'viber', 'id': 'dev_', 'slug': '', 'enabled': true, 'channelId': null}], 'welcomeMessage': { 'text': null, 'markup': 'PLAIN', 'attachments': null, 'buttons': [{ 'type': 'HyperLinkButton', 'text': 'Читать статью', 'link': 'https://blog.textback.ru/notifications_in_messengers' }] }, 'title': {'value': 'test heading'}, 'description': {'value': 'test desc\r\nline'}, 'markUp': { 'body': {}, 'icon': {'type': 'preset'}, 'header': {'value': 'привет это тестовый заголовок чтобы понять какое нормальное число знак'}, 'description': {'value': 'это тестовый заголовок чтобы понять какое нормальное число знаков может быть в описании чтобы было читабельно и красиво и вообще нормально. это очень длинное название, прямо очень длинное очень приоче'}, 'title': {'value': 'asdadad'} }, 'displayOptions': {}, 'displayMode': 'popup' }, '$count': 1 }); }); app.post('/api/endUserNotifications/deepLinks', (req, res) => { res.json({ '$error': null, '$items': null, '$value': 'subscribe_XXX', '$count': 1 }); }); app.listen(port, () => { console.log(`Application started on http://localhost:${port}`) });