npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

simple-ql

v0.13.37

Published

A node framework to manage your backend and your database with the least possible amount of code.

Downloads

97

Readme

WARNING: This is still in development and not yet ready for production. Use at your own risks!

SimpleQL

A node framework to manage your backend and your database with the least possible amount of code

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

Installation

npm install simple-ql -S

API

Check the wiki (links are at the bottom of this page).

Creating your server

const { createServer } = require('simple-ql');
const express = require('express');

//Prepare your tables
const tables = {
    ...
}
//Log into your database solution like mysql
const database = {
    user: ...
    password: ...
    host: ...
    type: 'mysql',
    privateKey: ...
    port: ...
    ...
}
//Create your access table
const access = {
    ...
}
//Create your plugins
const plugins = [
    loginPlugin({...}),
    customPlugin(),
    ...
]

const app = express();
app.listen(80);
const root = '/';//This is the path the SimpleQL requests should be addressed to. It will default to '/'.
createServer({app, tables, database, rules, plugins, root});

Note: You can also add options like the root path of the api, the sizeLimit of acceptable requests, or the number of requestPerMinute the api should handle, as parameter of the createServer function:

createServer({app, tables, database, rules, plugins}, {sizeLimit: '50mb', requestPerMinute: 100, root: '/'});

Read more about the optionnal parameter.

Examples

  • You can find here a full example of a messenger-like SimpleQL server configuration
  • You can find here a complete backend to host user files and manage data limitation.

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

To go deeper

Prepare your tables

Setup access to your database (like MYSQL)

Setting access rights

Adding plugins

Requesting your database

Server options

Testing