End to end working example that integrates Hacker News with Common Room.
This project provides a service that fetches data from Hacker News and integrates it with Common Room. The service performs the following tasks:
- Fetch Historical Data: Retrieves historical stories from Hacker News based on specified story types.
- Subscribe for Updates: Subscribes to real-time updates from Hacker News and processes new stories as they are published.
- Filter and Process Stories: Filters stories and comments to only those that match the configured keywords and processes them to be added to Common Room.
- Clone the Repository:
git clone https://github.com/your-username/hacker-news-integration.git
cd hacker-news-integration
- Install Dependencies:
npm install
Update the following config files with keywords, tokens, and destinationSourceId:
- appConfig.js
- commonRoomConfig.js
To run the application locally, use the following command:
npm start
To run the application in a Docker container, install Docker and follow these steps:
- Build the Docker Image
docker build -t hacker-news-integration .
- Run the Docker Container
docker run -d --name hacker-news-integration-container hacker-news-integration
There are many options for deploying the integration to a cloud service. In this example, we'll walk through how you can deploy the Docker container to AWS Fargate, Amazon's serverless compute engine. This will allow us to deploy our container without having to worry about managing the underlying infrastructure.
-
Create an ECS Cluster
- Open the Amazon ECS Console: Navigate to the Amazon ECS console.
- Create a Cluster: Click on "Create Cluster" and select the "Networking only" option for Fargate.
- Configure Cluster: Provide a name for your cluster and click "Create".
-
Create an ECR Repository
- Open the Amazon ECR Console: Navigate to the Amazon ECR console.
- Create a Repository: Click on "Create repository" and name your repository
hacker-news-integration
. - Note the Repository URI: You will need this URI to push your Docker image.
-
Build and Push Your Docker Image to ECR
-
Authenticate Docker to Your ECR Registry:
aws ecr get-login-password --region <your-region> | docker login --username AWS --password-stdin <your-aws-account-id>.dkr.ecr.<your-region>.amazonaws.com
You can use the
aws configure
command to set up your access key ID, secret access key, region and output if you haven't already done so. You can read more here. -
Build the Docker Image:
docker build -t hacker-news-integration .
-
Tag the Docker Image:
docker tag hacker-news-integration:latest <your-aws-account-id>.dkr.ecr.<your-region>.amazonaws.com/hacker-news-integration:latest
-
Push the Docker Image to ECR:
docker push <your-aws-account-id>.dkr.ecr.<your-region>.amazonaws.com/hacker-news-integration:latest
-
-
Create a Task Definition
- Open the Amazon ECS Console: Navigate to the Amazon ECS console.
- Create a Task Definition: Go to "Task Definitions" and click "Create new Task Definition".
- Select Fargate: Choose the Fargate launch type.
- Configure the Task Definition:
- Container Name: Provide a name for your container.
- Image: Specify the Docker image URI (e.g. <your-account-id>.dkr.ecr.<your-region>.amazonaws.com/hacker-news-integration:latest).
- Memory Limits: Set the memory limits.
- Port Mappings: Map the container port to a host port (e.g., 3000:3000).
-
Create a Service
- Create a Service: In the ECS console, go to "Services" and click "Create".
- Configure the Service:
- Launch Type: Select Fargate.
- Task Definition: Choose the task definition you created.
- Cluster: Select the cluster you created.
- Service Name: Provide a name for your service.
- Number of Tasks: Specify the number of tasks to run.
- VPC and Subnets: Select the VPC and subnets for your service.
- Security Groups: Configure security groups to allow traffic to your container.
-
Deploy the Docker Container
- Deploy the Service: Click "Create Service" to deploy your Docker container.
- Monitor the Deployment: Use the ECS console to monitor the deployment and ensure that your container is running.
Contributions are welcome! Please open an issue or submit a pull request.