What I built
A realtime integration for the Ghost blogging platform. This includes:
- A backend HTTP service
- An example frontend library for Ghost's 'Casper' - theme
As a bonus: My LaMetric clock was in the mail today π. It can receive notifications about new and updated posts, so I integrated a dedicated code snippet in this submission. Check out the readme on Github on how to use it together with Ghost notifier. I'm also listing a brief showcase video under 'Additional Resources/Info'.
Category Submission:
About real-time
App Link
This service aims to be self-hosted. I'm providing a docker setup with Ghost + a step-by-step guide on registering the necessary webhooks as part of the readme on Github.
Screenshots
Please see the Github readme for screenshots
Description
Ghost-Notifier does two things.
1. It receives a published article as input and stores a notification
- Ghost-Notifier is a microservice built on top of MongoDB and Express.js.
- It receives Ghost articles over HTTP and stores a subset of their data in MongoDB.
2. It produces output when a DB change is detected and sends it to connected clients
- Third-party clients can subscribe to Ghost-Notifier via. HTTP(S)
- When a publisher creates or updates a post, MongoDB triggers a notification using its built-in Change Streams
- This notification is sent via Server-Sent-Event to connected clients
Link to Source Code
tq-bit
/
ghost-notifier
A realtime application that provides notification messages for your Ghost Blog. Winner of the MongoDB Atlas Hackathon 2022
Ghost-Notifier
Winner of the MongoDB Hackathon 2022 on dev.to
Realtime notifications for your Ghost Blog
About the Project
This project is a selfhosted MVP for realtime notifications in Ghost CMS. It's my submission to the 2022 MongoDB hackathon on dev.to.
Ghost Notifier is built on top of MongoDB ChangeStreams and Ghost webhooks to deliver notifications whenever a new article is published or an existing article is updated.
Built With
- MongoDB Atlas
- Typescript / Javascript
- Handlebars
- feat. Ghost CMS
- feat. LaMetric
Get started
I've added to alternate ways for your to give this application a ride:
- Simulate Ghost Webhooks with a HTTP client and check the app logs on localhost:3000/ (the 'Simulation approach')
- Start a Ghost Instance locally, register webhooks and the frontend library (the 'Ghost approach')
In the following, I'll explain both in greater detail.
Quickstart
Start by cloning this repos into a folder of your choice andβ¦
Permissive License
MIT
Background
I'm using Ghost CMS to write about web development. The platform's been a valuable asset in my toolkit for the last two years and continues to be so.
Compared to other blogging platforms, Ghost aims to be lightweight in design. It includes no classic plugins, but uses webhooks to trigger third party extensions to tweet, share or trigger workflows.
My blog does not receive enough traffic to add a lot of them. But if I ever attempted to scale, I'd look for more ways to keep users engaged. For instance, with notifications about new content.
Here's where MongoDB ChangeStreams seemed a perfect match for Ghost's webhooks.
How I built it
Ghost-Notifier is a Typescript backend built on Express.js. It uses MongoDB Atlas to store a subset of post data on two events:
- New post published
- Published post updated
These posts are stored and trigger MongoDB's ChangeStream
functionality.
Using MongoDB instead of in-mem DBs opens the gate to even more features:
- Use MongoDB's toolkit, including sharding, transactions and the query API to make scaling a child's play.
- It's easier to apply advanced analytics if you run Ghost-Notifier as SAAS <- this would be how I host this app as a product
- You can keep building on MongoDB's native driver to quickly implement further features, such as a URL-shortener or a search index
I also picked up Server-Sent-Events (SSE) along the way. In this case, they deliver notifications to connected clients whenever a DB entry is updated. I even wrote an article about implementing this technique because I found it to be a valuable alternative to Websockets
MongoDB and SSE play incredibly well together and were swiftly implemented. I'll definitely use this combination more often from now on for stateful realtime-applications.
Additional Resources/Info
- Video for the LaMetric integration example: https://youtube.com/shorts/Mdwa-9BS4W4
- The article I wrote about Node.js + SSE: https://dev.to/tqbit/how-to-use-nodejs-for-server-sent-events-sse-5ggj
- MongoDB Change Streams docs: https://www.mongodb.com/docs/manual/changeStreams/
- MDN on server-sent-events: https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events
- MongoDB vs. Redis comparison: https://www.mongodb.com/compare/mongodb-vs-redis
- Ghost Webhooks docs: https://ghost.org/docs/webhooks/
Top comments (2)
This is a cool project!
Looks great!