A Chaos slides generator build for the community cafe at MongoDB World.
This slide generator will build a slide deck of however many slides you want.
The images from the slides can be either from a MongoDB Collection, or from Giphy.
Create a MongoDB Atlas account, and start up a new free cluster.
Create a new database chaos
with a collection slides
. You can add new documents to the database. The documents should have an image
field.
{ _id: "...", image: "https://example.com/full/path/to/image.png" }
Go to the Application Services, and create a new serverless Function. Name this function getRandom
, and put in the following code.
exports = async function(arg){
const NUMBER_OF_SLIDES = parseInt(arg.query.num) || 4;
const collection = context.services.get("mongodb-atlas").db("chaos").collection("slides");
const slides = await collection.aggregate([{$sample:{size: NUMBER_OF_SLIDES}}]);
return slides;
}
Create an HTTPS endpoint, and make sure that it runs the function you just create on GET requests.
Go to the Giphy Developers page and create an account. From there, create a new API key.
In the index.js
file, fill in the values for the first two variables.
const GIPHY_KEY = "Your Giphy API Key";
const SLIDES_ENDPOINT = "Your Atlas HTTPS Endpoint";
Use a static file web server such as serve, or use MongoDB's Atlas hosting service to host your files.
You can change the assets/intro.png
file to customize the intro slide as you see fit.