Skip to content

Add activity feed API #1081

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions graphite-demo/server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const express = require('express');
const app = express();
const port = 3000;

// Fake data for the activity feed
const activityFeed = [
{
id: 1000,
title: 'New Photo Uploaded',
body: 'Alice uploaded a new photo to her album.'
},
{
id: 2000,
title: 'Comment on Post',
body: "Bob commented on Charlie's post."
},
{
id: 13,
title: 'Status Update',
body: 'Charlie updated their status: "Excited about the new project!"'
}
];

app.get('/feed', (req, res) => {
res.json(activityFeed);
});

app.listen(port, () => {
console.log(`Server running on port ${port}`);
});
Comment on lines +1 to +30
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Verify repo dependencies and potential port conflicts

Ensure express is declared and check for other listeners on port 3000 to avoid collisions when running the demo.

Run this script from the repo root:


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

echo "== Checking for package.json files and express dependency =="
fd -a -t f -g package.json | while read -r pkg; do
  echo "---- $pkg ----"
  if jq -e '.dependencies.express // .devDependencies.express' "$pkg" >/dev/null 2>&1; then
    echo "express declared:" "$(jq -r '.dependencies.express // .devDependencies.express' "$pkg")"
  else
    echo "express not declared in this package.json"
  fi
done

echo
echo "== Searching for other servers that call listen(...) or use port 3000 =="
# Look for listen() calls (avoid node_modules)
rg -n -C2 -g '!**/node_modules/**' -P '\blisten\s*\(\s*(process\.env\.PORT|\d+)' || true

# Explicit port 3000 occurrences (outside node_modules)
rg -n -C2 -g '!**/node_modules/**' -P '\b3000\b' || true

echo
echo "== If express is missing, install with =="
echo "npm install express"

Length of output: 58521


Ensure Express is declared and make the port configurable to avoid collisions

• Add an explicit package.json in graphite-demo/ (or update the existing one) with Express as a dependency, e.g.:

{
  "name": "graphite-demo",
  "version": "1.0.0",
  "dependencies": {
    "express": "^4.18.2"
  }
}

• In graphite-demo/server.js, replace the hard-coded port with an environment-override:

- const port = 3000;
+ const port = process.env.PORT || 3000;

• Note that other components (e.g. Langtrace agents in src/praisonai-agents) default to localhost:3000. If you run both services locally, pick different ports or override via PORT to prevent conflicts.

🤖 Prompt for AI Agents
In graphite-demo/server.js lines 1 to 30, make the port configurable and ensure
express is declared properly: keep the existing require('express') but replace
the hard-coded port with a value read from process.env.PORT (e.g. const port =
process.env.PORT || 3000) so callers can override it to avoid collisions;
additionally add or update graphite-demo/package.json at the project root to
declare express as a dependency (name, version and "express": "^4.18.2") so npm
install will install Express.

Loading