jsonqlweb

1.0.3 • Public • Published

JSONQL

About

Simple implementation of RPC server like GraphQL.

Install

At this time we don't have npm package, you need to clone repo.

https://github.com/WebStyle/jsonql.git

install deps:

cd jsonql && npm install

Quick example:

import { JsonQLServer, Type, Field } from "./src";


class Company {
    @Field() name
}

@JSONQLType
class User {
    @Field() a: number;
    @Field() b: string;
    @Field() company: Company;
}

// Quick example
const app = new JsonQLServer({
    add: async (params: User, fields: string[]) => {
        const { a, b } = params;
        return { a, b, data: a + b, name: 'Farrukh'+ a+b };
    },
    list: async (params, fields: string[]) => {
        return [{ name: 'Martin', id: 1 }, { name: 'John Doe', id: 2 }];
    }
});
app.listen(3000);
console.log('Server is run on 3000');

Request example:

{
	"method": "add",
	"params": { "a": 1, "b": 2 },
	"fields": ["a"]
}	

/jsonqlweb/

    Package Sidebar

    Install

    npm i jsonqlweb

    Weekly Downloads

    0

    Version

    1.0.3

    License

    ISC

    Unpacked Size

    31.5 kB

    Total Files

    42

    Last publish

    Collaborators

    • webstyle