Grapite : Cache Handler for your API , faster , better and with time interval feature
Problem
So i was making a project where I needed a cache handler for my API's so I landed upon Redis but instantly realised that redis is a bit hard to setup and is slower than what I needed plus I have no customization options on time intervals so I took upon myself to make one myself using Graphql
Grafbase introduction
I came to know that Grafbase is organizing an hackathon and this was a perfect time to use the ease of grafbase software to make graphql API for caching software of mine. I decided to call it Grapite!
So what exactly is Grapite?
Grapite is a cache handler for API and essentially a middleware between Backend and frontend of your website.
It manages cache so that your API requests can be less expensive, you can customize it by adding time interval to refresh API so that fresh data can be loaded with latency of as low as of staggering 50ms.
How to use it?
- Download grapite from:-
- Run it using
npm run dev
You are done, it will be up and running on 'http://localhost:5000/grapite'
How to access it?
You have to add apiname and model in the folder first.
then you can make request immediately using
'http://localhost:5000/grapite/get/apiname/modelname'
'http://localhost:5000/grapite/post/apiname/modelname'
What are apiname and modelname?
for example:- apiname is newsapi
then model will be different customizable function you want to run when the model is called in those function will be your API get or post endpoints using which you receive or send data.
i wanted to add UI to not do this manually by user just like grafbase pathfinder but there isn't enough time left for hackathon end so I will add that later.
For time being you can add model by going to folder 'grapite/Main/Extra/functions' and make a '.js ' file with function and return statement'
To test it without manually adding function
I have already made a default model named worldnews
Lets say you made 'worldnews' model in 'news' apiname
to access it use 'http://localhost:5000/grapite/get/news/worldnews'
with body { name : "defAULT",body:{}}
you are all set
Technologies used
Grafbase and nodejs
Important links
project - https://github.com/captain0jay/grapite
my LinkedIn - https://www.linkedin.com/in/captain-jay-34a083229/
UI COMING IN 1-2 DAYS,
Thanks for reading :)
Subscribe to my newsletter
Read articles from Web Escape directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by