-
Notifications
You must be signed in to change notification settings - Fork 2
Home
A node framework to manage your backend and your database with the least possible amount of code
SimpleQL is a NodeJS framework to create a server in 10 minutes that will handle all kind of data and requests without requiring you to do any low-value logic server-side, nor develop any endpoint. Define a general behaviour that will quickly get you a database working and able to treat all kinds of requests, and then you can add your custom logic where it is needed and valuable.
- Simple: Only one route for all your requests
- Predictable: the response of any SimpleQL request is formatted exactly the same way as the request, so you don't need to wonder about what the result of a request will looks like.
- Efficient: In one single request you can do everything!
npm install simple-ql -S
const { createServer } = require('simple-ql');
//Prepare your tables
const tables = {
...
}
//Log into your database solution like mysql
const database = {
login: ...
password: ...
host: ...
type: 'mysql',
privateKey: ...
port: ...
...
}
//Create your access table
const access = {
...
}
//Create your plugins
const plugins = [
loginPlugin({...}),
customPlugin(),
...
]
createServer({port : 80, tables, database, rules, plugins})
Note: You can also add a list of express middlewares and an error handler directly as parameter of the createServer
function:
const middleware = (req, res, next) => next();
const middlewares = [middleware];
const errorHandler = (err, req, res, next) => next(err);
createServer({port : 80, tables, database, rules, plugins, middlewares, errorHandler});
Example: You can find here a full example of a messenger-like SimpleQL server configuration
This is what a SimpleQL request will look like:
{
Comment : {
author: {
email : '[email protected]',
},
date : {
'<=' : new Date(new Date(date).setHours(date.getHours() + 2)).toISOString(),
'>=' : new Date(new Date(date).setHours(date.getHours() - 2)).toISOString(),
},
set : {
title : 'random',
}
}
}
Example: You can find here a set of requests matching the previous server example
In one request, we are getting all the messages from [email protected]
published 2h around date
, and we are changing their title to random
. This is what the response will looks like:
{
Comment: [
{
title: 'random',
date: '2019-05-05T05:10:32.000Z',
author: { email: '[email protected]' },
lastModification: '2019-05-05T06:01:33.005Z',
edited: true,
}
]
}