10 examples of 'mongoose push' in JavaScript

Every line of 'mongoose push' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
35export function registerForPush(api: Api): Promise {
36 return new Promise(async (resolve, reject) => {
37 /**
38 * First we ask YT for token and exit if YT does not support PUSH notifications
39 */
40 let ytToken: string;
41 try {
42 log.debug(`Getting YT notifications token...`);
43 ytToken = await api.getNotificationsToken();
44 log.debug(`YT notifications token received: "${ytToken}"`);
45 } catch (err) {
46 if ([400, 404, 405].includes(err?.status)) {
47 log.debug('YouTrack server does not support push', err);
48 return reject(new Error('YouTrack does not support push notifications'));
49 }
50 throw err;
51 }
52
53 /**
54 * Then we register for push notifications with this token
55 */
56 async function onRegister(deviceToken): Promise {
57 NotificationsIOS.removeEventListener('remoteNotificationsRegistered', onRegister);
58 try {
59 const url = `${KONNECTOR_URL}/ring/pushNotifications`;
60 await api.makeAuthorizedRequest(url, 'POST', {token: ytToken, appleDeviceId: deviceToken});
61 resolve();
62 } catch (err) {
63 reject(err);
64 }
65 }
66 NotificationsIOS.addEventListener('remoteNotificationsRegistered', onRegister);
67
68 async function onRegistrationError(e) {
69 NotificationsIOS.removeEventListener('remoteNotificationsRegistrationFailed', onRegistrationError);
70 log.info('PUSH: registration error', e);
71 reject(e);
72 }
73 NotificationsIOS.addEventListener('remoteNotificationsRegistrationFailed', onRegistrationError);
74
75 // $FlowFixMe: error in type annotations of library
76 NotificationsIOS.requestPermissions();
77 });
78}
82registerPush(): Promise {
83 return;
84}
17function push(payloadArray) {
18 console.log(payloadArray);
19 $.each(payloadArray, function (index, payload) {
20 var img_tag = "";
21 var html = "<a href="&quot; + payload.link + &quot;">" + img_tag + "</a>";
22 $('.stage').prepend(html);
23 });
24}
4function push ({firebase, path, resolve}) {
5 return createReturnPromise(
6 firebase.push(resolve.value(pushPath), resolve.value(value)),
7 path
8 )
9}
4constructor() {
5 this.model = new PushModel();
6}
6push(...transactions) {
7 return Promise.all(transactions.map(event =&gt; {
8 return new Promise((resolve, reject) =&gt; {
9 this.queue.push({ event, resolve, reject })
10 if (1 === this.queue.length) this._shift()
11 })
12 }))
13}
117initListener(callback) {
118 var _this = this;
119 var pubsub = this.pubsub;
120
121 pubsub.on("listen", function () {
122 callback();
123 });
124
125 pubsub.on('error', function (err) {
126 callback(err);
127 debug('Error', err);
128 });
129
130 pubsub.on('denied', function (err) {
131 debug('Denied', err);
132 });
133
134 pubsub.on('feed', function (data) {
135 try {
136 var feed = _this.prepareData(data.feed.toString());
137 _this.main.events.emit('feed', feed);
138 } catch (err) {
139 if (err.message === 'Entry is not found!') {
140 return;
141 }
142
143 debug('Parse xml error!', err);
144 }
145 });
146
147 this.pubsub.listen(_this.main.config.push.port);
148}
1module.exports = function push (remote) {
2 return `git push ${remote || 'heroku'} master`
3}
8export default async function push(stream: http2.ServerHttp2Stream, pushCtx: Context) {
9
10 const requestHeaders = {
11 ':path': pushCtx.request.requestTarget,
12 ...pushCtx.request.headers.getAll(),
13
14 };
15 let pushStream: http2.ServerHttp2Stream;
16
17 try {
18 pushStream = await getPushStream(
19 stream,
20 requestHeaders,
21 );
22 } catch (err) {
23 if (err.code === 'ERR_HTTP2_PUSH_DISABLED') {
24 // HTTP/2 disabled pusing after all
25 return;
26 }
27 throw err;
28 }
29 pushStream.on('error', err =&gt; {
30
31 const isRefusedStream =
32 pushStream.rstCode === http2.constants.NGHTTP2_REFUSED_STREAM;
33
34 if (!isRefusedStream) {
35 throw err;
36 }
37
38 });
39 pushStream.respond({
40 ':status': 200,
41 ...pushCtx.response.headers.getAll(),
42 });
43 sendBody(pushStream, pushCtx.response.body);
44
45}
17registerNotificationListener(listener) {
18 if (Platform.OS === 'ios') {
19 PushNotification.onNotification = (notification) =&gt; {
20 listener(notification);
21 notification.finish(PushNotificationIOS.FetchResult.NoData);
22 };
23 } else {
24 PushNotification.onNotification = listener;
25 }
26}

Related snippets