Skip to content

Instantly share code, notes, and snippets.

@sohamdodia
sohamdodia / aws-sns-push-notification-for-android
Last active July 24, 2018 12:19
Code snippet to send push notifications to android device using AWS push notification service.
const AWS = require ('aws-sdk');
AWS.config.update({
accessKeyId: 'ACCESS_KEY',
secretAccessKey: 'SECRET_KEY',
region: 'REGION'
});
const sns = new AWS.SNS();
sns.createPlatformEndpoint({
@sohamdodia
sohamdodia / async-await
Last active May 31, 2018 09:44
Async await Example.
/**
* without using async/await
*/
exports.updateUserAndSendEmail = (req, res) => {
User.findOne({ email: req.body.email }, (error, retrievedUser) => {
if (error) {
console.log('error');
}
if(retrievedUser) {
@sohamdodia
sohamdodia / aws-sns-sms-node
Last active May 29, 2018 09:29
Code snippet to send sms using AWS SNS.
const AWS = require('aws-sdk');
AWS.config.update({
region: 'region', //https://docs.aws.amazon.com/sns/latest/dg/sms_supported-countries.html follow this link for supported region
accessKeyId: 'access key',
secretAccessKey: 'secret key'
});
const sns = new AWS.SNS();
const params = {
Message: 'Your OTP is 123456',
worker_processes 1;
events {
worker_connections 1024;
}
http {
server {
listen 80;
const express = require('express');
const app = express();
const port = 3000;
app.get('/', (req, res) => {
res.send('Hello World');
});
app.listen(port, () => {
console.log(`Server started on port ${port}`);