🚀 JetQL
JetQL is a query language for the implementation of Rest APIs on both the server and the client. JetQL also comes with a frontend script that easily connects it to the backend.
JetQL is inspired by GraphQL but extremely simplified.
You can donate to the project in Paypal, in Ko-fi or in Patreon
JetQL Features:
- 🧹 Clean Sintaxis.
- 🔗 Compatble with POST, PUT, DELETE and GET Requests.
- 🚀 Fast and Lightweight.
- 🙏 Express.js compatible.
How does this work?
JetQL registers all routes that start with /api, thus intercepting the request. Following this, it analyzes the body of the request (In case of being POST) or analyzes the url used (In case of being GET) to obtain a query command and execute it internally.
The body has this format:
And the url (in case of being GET) has this format:
http://example.com/api/<route>/<action>/<props>/<args>
Get started with JetQL
Implementation with express:
const express = ;const JetQL = ; const app = ;const jetql = JetQL; app;app; app;
Implementation in the frontend:
(Import the script file)
(Send a request)
Send request
Test route in backend:
jetql;
Examples
Add a route (Method #1):
jetql;
Add a route (Method #2):
jetql;
Add external route:
// index.jsjetql; // external.jsconst JetQL = ;const router = JetQL; router;router;router; moduleexports = router;
Demo
Try jetql with the demo project.
- Clone the repository
- Use node ./jetql.test.js in the folder.
- Open https://127.0.0.1:4000/
Methods
End the request with a successful result:
query;
End the request with a 404 error and a message:
query;
The request ends with a 500 error and a message:
query;
Get the client's request:
queryrequest;
Get the response to the client:
queryresponse;
Add a router object and all its routes to the JetQL instance:
jetql;
Add a route to the jetql instance:
jetql;
Add a route to the jetql instance:
jetql;
Gets the express middleware:
jetql;
Gets the http middleware:
jetql;
Instantiate jetql:
jetql;