Comparing version 0.0.1 to 0.0.2
@@ -6,10 +6,48 @@ "use strict"; | ||
}); | ||
exports.default = pompeii; | ||
exports.handler = void 0; | ||
/** | ||
* This is the main package file. | ||
*/ | ||
async function pompeii() { | ||
console.log('pompeii called'); | ||
} | ||
var _awsSdk = _interopRequireDefault(require("aws-sdk")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
const sns = new _awsSdk.default.SNS(); | ||
const { | ||
env: { | ||
TOPIC_ARN: TopicArn | ||
} | ||
} = process; | ||
const NPM_FROM = /support@npmjs\.com/; | ||
const handler = async ({ | ||
Records | ||
}) => { | ||
const [{ | ||
ses: { | ||
} | ||
}] = Records; | ||
const { | ||
commonHeaders: { | ||
from, | ||
subject | ||
} | ||
} = mail; | ||
if (!NPM_FROM.test(from)) { | ||
console.log('not publishing'); | ||
return; | ||
} | ||
console.log('publishing %s', subject); | ||
await publish(subject); | ||
}; | ||
exports.handler = handler; | ||
const publish = async Message => { | ||
await sns.publish({ | ||
TopicArn, | ||
Message | ||
}); | ||
}; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "pompeii", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "A lambda function to notify of npm releases.", | ||
@@ -5,0 +5,0 @@ "main": "build", |
@@ -1,6 +0,25 @@ | ||
/** | ||
* This is the main package file. | ||
*/ | ||
export default async function pompeii() { | ||
console.log('pompeii called') | ||
import AWS from 'aws-sdk' | ||
const sns = new AWS.SNS() | ||
const { env: { TOPIC_ARN: TopicArn } } = process | ||
const NPM_FROM = /support@npmjs\.com/ | ||
export const handler = async ({ Records }) => { | ||
const [{ ses: { mail } }] = Records | ||
const { commonHeaders: { from, subject } } = mail | ||
if (!NPM_FROM.test(from)) { | ||
console.log('not publishing') | ||
return | ||
} | ||
console.log('publishing %s', subject) | ||
await publish(subject) | ||
} | ||
const publish = async (Message) => { | ||
await sns.publish({ | ||
TopicArn, | ||
Message, | ||
}) | ||
} |
Sorry, the diff of this file is not supported yet
7646
127