Skip to content

Instantly share code, notes, and snippets.

//frontend/src/Notification.js
const Notification = (activity) => {
if (activity.activityGroup.verb === "comment") {
if (activity.activityGroup.activity_count <= 1) {
return (
<div className="notification">
<div className="notification-header">
<img className="icon-wide" src={youtubeIcon} alt="youtube-icon" />
<div className="youtube">
<strong>New YouTube Comment</strong> from{" "}
//backend/routes/index.js:44
const upload = multer();
router.post("/sendgrid-webhook-endpoint", upload.none(), async function (req, res) {
try {
let actor;
let verb;
let object;
let body;
//frontend/src/App.js:29
if (streamCredentials) {
return (
<div>
<h2 className="app-title">Stream Custom Email Notifications</h2>
<div className="container">
<StreamApp
className="stream-app"
apiKey={streamCredentials.apiKey}
token={streamCredentials.token}
//backend/routes/index.js:16
router.get("/registration", async (req, res) => {
try {
await client.user("example-user").getOrCreate({
name: "example-user",
});
await client.user("sendGrid").getOrCreate({
name: "sendGrid",
});
//backend/routes/index.js:8
require("dotenv").config();
const streamApiKey = process.env.STREAM_API_KEY;
const streamApiSecret = process.env.STREAM_API_SECRET;
const appId = process.env.STREAM_APP_ID;
const client = stream.connect(streamApiKey, streamApiSecret);
//frontend/src/App.js:12
const [streamCredentials, setStreamCredentials] = useState(null);
useEffect(() => {
async function register() {
try {
var response = await axios.get("http://localhost:8080/registration");
setStreamCredentials({
token: response.data.userToken,
//backend/.env.example
NODE_ENV=development
PORT=8080
STREAM_API_KEY='your stream API key here'
STREAM_API_SECRET='your stream secret here'
STREAM_APP_ID='your app id here'
//frontend/src/Post.js:5
const Post = ((props) => {
if (props.activity.object === 'GetObject') {
return (
<div>
<hr className="hr-class" />
<div className='post'>
<img className="actor-logo" alt="download-icon" src={dlIcon} />
<div className="post-content">
<p className="post-title"><b>{props.activity.s3UserName}</b> viewed <b>{props.activity.objectName}</b> from the bucket: <b>{props.activity.bucketName}</b>.</p>
//api/routes/index.js:44
router.post('/lambda', async function (req, res) {
try {
const s3 = client.feed('s3_activities', 's3');
await s3.addActivity({
'actor': 's3',
'verb': 'post',
'object': req.body.eventName,
's3UserName': req.body.user,
//frontend/src/App.js:33
if (streamCredentials) {
return (
<div ref={containerRef}>
<StreamApp apiKey={streamCredentials.apiKey} token={streamCredentials.token} appId={streamCredentials.appId}>
<div className="stream-app">
<h3 className="app-title">S3 Monitor</h3>
</div>
<FlatFeed
feedGroup="user_notifications"