Skip to content
François Billioud edited this page May 5, 2019 · 6 revisions

Welcome to the SimpleQL wiki!

You will find in those links everything you need to start your SimpleQL server in 10 minutes.

What the heck is SimpleQL and why should I bother?

SimpleQL is a NodeJS framework to create a server in 10 minutes that will handle al kind of data and requests without requiring you to do any logic server-side, nor develop any endpoint.

  • 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!

Installation

npm install simple-ql -S

Creating your server

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})

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',
        }
      }
    }

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,
    }
  ]
}
Clone this wiki locally