Skip to content

Instantly share code, notes, and snippets.

View dzmitry-kankalovich's full-sized avatar
🚀

Dmitry Kankalovich dzmitry-kankalovich

🚀
View GitHub Profile
import * as cdk from '@aws-cdk/core';
export class NotionRssFeedStack extends cdk.Stack {
constructor(scope: cdk.App, id: string, props?: cdk.StackProps) {
super(scope, id, props);
// your stack definition would go here
}
}
@dzmitry-kankalovich
dzmitry-kankalovich / index.js
Created May 16, 2021 15:56
Notion RSS - Lambda base
const Parser = require('rss-parser');
const parser = new Parser();
exports.handler = async function (event) {
console.log("request:", JSON.stringify(event, undefined, 2));
const feed = await parser.parseURL('http://aws.amazon.com/rss/whats-new.rss');
return {
statusCode: 200,
headers: { "Content-Type": "text/plain" },
body: `${feed.description}`
};
@dzmitry-kankalovich
dzmitry-kankalovich / notion-rss-feed-stack.ts
Created May 16, 2021 15:58
Notion RSS - Stack with Lambda
import * as cdk from '@aws-cdk/core';
import * as lambda from '@aws-cdk/aws-lambda';
export class NotionRssFeedStack extends cdk.Stack {
constructor(scope: cdk.App, id: string, props?: cdk.StackProps) {
super(scope, id, props);
// Create the RSS Feed Lambda function
const handler = new lambda.Function(this, 'NotionRssFeedHandler', {
runtime: lambda.Runtime.NODEJS_14_X,
code: lambda.Code.fromAsset('resources/lambda'),
@dzmitry-kankalovich
dzmitry-kankalovich / notion-rss-feed-stack.ts
Created May 16, 2021 16:05
Notion RSS - Configuration
import * as cdk from '@aws-cdk/core';
import * as lambda from '@aws-cdk/aws-lambda';
import { config } from 'dotenv';
config()
const NOTION_INTEGRATION_TOKEN = process.env.NOTION_INTEGRATION_TOKEN || '';
const NOTION_PAGE_NAME = process.env.NOTION_PAGE_NAME || '';
const RSS_FEED_URL = process.env.RSS_FEED_URL || '';
@dzmitry-kankalovich
dzmitry-kankalovich / index.js
Created May 16, 2021 16:06
Notion RSS - final Lambda
const Parser = require('rss-parser');
const { Client } = require("@notionhq/client");
const parser = new Parser();
const notion = new Client({ auth: process.env.NOTION_INTEGRATION_TOKEN });
const page_name = process.env.NOTION_PAGE_NAME;
const feed_url = process.env.RSS_FEED_URL;
exports.handler = async function (event) {
@dzmitry-kankalovich
dzmitry-kankalovich / notion-rss-feed-stack.ts
Last active May 16, 2021 16:25
Notion RSS - final stack
import * as cdk from '@aws-cdk/core';
import * as lambda from '@aws-cdk/aws-lambda';
import * as targets from "@aws-cdk/aws-events-targets";
import * as events from "@aws-cdk/aws-events";
import { config } from 'dotenv';
config()
const NOTION_INTEGRATION_TOKEN = process.env.NOTION_INTEGRATION_TOKEN || '';
const NOTION_PAGE_NAME = process.env.NOTION_PAGE_NAME || '';