Workshop: NodeJS Hello World
This example provides the steps to build a simple API using hyper and NodeJS. It includes:
- hyper Data API : a scalable database solution with a clean separation from business logic and service implementation
- hyper Cache API : a scalable cache solution that gives JSON document Key Value features with Time To Live functionality
- hyper Search API : a scalable search solution that makes it as simple as a click to spin up a search index
- ο»ΏZod: a data validation utility that empowers the development team to manage their data model in the business layer of the application
By the end of this workshop, you'll have an API service that allows users to create, update, list, view, search and delete video game documents.

Whenever you get stuck at any point, take a look at this repo
Before we get started we need to setup our hyper services, This is as simple as logging into the hyper dashboard and clicking add application - You can name the application whatever you like (ie. [initials]-video-game-api) and make sure that both the data and cache services are selected. Awesome!
When the app is created, copy the Connection String on the keys tab, by clicking the copy icon to the right of the string.
In a command-line terminal window type the following commands:
Let's start building our API from scratch!
Open the server.js file in your code editor and type the following:
Open your browser to port 3000 and you should see:
Video Game API in text in the browser window!
Let's use a free API tool to talk to our API. https://hoppscotch.io/
Open hoppscotch in a new browser tab and set the method to be GET and enter in your server address: http://localhost:3000 - then click send - you should see the result 'Video Game API' in the response body.
create a new file called Game.js - This file will contain our document schema, and a validation function
In the server.js file lets create new express handler
You will want to add the API handler after the const declarations, but before the app.get handler.
Using hoppscotch, send a POST command to http://localhost:3000/games URL. It should return back a status of 500 and an error, showing that several elements are required!
Now, use the body tab in the hoppscotch UI to create our JSON document
You should see the response
Let`s add a game counter in our cache, this counter will count every game added to the data store.
First, create a incrementCounter utility method
utils.js
In the server.js let's modify the promise chain in the app.post handler
Now add another game using hoppscotch
Using the hyper-vision tool, we can look at our data and cache services: https://vision.hyper.io - paste the connection string from the .env file, and go to the cache section, you should see a game-counter key, and the value should be { count: 1 }
Its time to create the get document by id endpoint, GET /games/:id
`server.js`
create a new API handler underneath the post handler:
Using hoppscotch lets get a game document, modify the method to GET and change the URL to http://localhost:3000/games/game-1 then click on the send button.
Response
server.js NOTE: make sure you add this above the app.get('/games/:id') handler
Using hoppscotch call the new endpoint GET /games/count
Response
Clients should be able to update Game documents, so lets make that happen, by creating a new API endpoint
Using hoppscotch lets update a game document, by setting the method to PUT and the URL to http://localhost:3000/games/game-1 and the body to the following and click the `send` button:
Here is the expected response
ο»Ώ
Let's delete a game document
update the utils.js , by adding decrementCounter
ο»Ώ
in the server.js file, create a app.delete handler
GET /games
ο»Ώ