Rearranged the files, adjusted the code slightly

This commit is contained in:
2020-09-19 09:03:55 +10:00
parent 1addf15a39
commit 6b7e55c05f
9 changed files with 48 additions and 73 deletions

View File

@@ -1,6 +1,6 @@
simpleQL is a web API query language that mimics graphQL, designed solely for fun.
sineQL is a web API query language that mimics graphQL, designed solely for fun.
simpleQL consists of two languages - the schema language, and the query language.
sineQL consists of two languages - the schema language, and the query language.
## The Schema Language
@@ -30,13 +30,11 @@ type Book {
}
type Author {
!String name
!Book[] books
String name
Book books
}
```
`[]` Represents an array of fields, while `!` represents a field that must not be omitted in queries (non-nullable).
## The Query Language
The query langauge can be used to request data from a server, either in whole or in part by listing it's type and it's fields, and subfields.

View File

@@ -107,22 +107,6 @@ const parseCompoundType = (tokens, pos) => {
let type = tokens[pos++];
const name = tokens[pos];
//parse the extra typing data
let array = false;
let required = false;
//not nullable
if (type[0] === '!') {
required = true;
type = type.slice(1);
}
//is array
if (type.endsWith('[]')) {
array = true;
type = type.slice(0, type.length - 2);
}
//no mangled types or names
checkAlphaNumeric(type);
checkAlphaNumeric(name);
@@ -139,9 +123,7 @@ const parseCompoundType = (tokens, pos) => {
//finally, push to the compound definition
compound[name] = {
typeName: type,
array: array,
required: required,
typeName: type
};
}
@@ -312,7 +294,6 @@ const lexify = (body, allowStrings) => {
//anything else is a multi-character token
const start = current;
while(body[current] && !/[{}"\s]/.test(body[current])) {
console.log('advancing past', body[current]);
current++;
}
tokens.push(body.substring(start - 1, current));
@@ -321,7 +302,6 @@ const lexify = (body, allowStrings) => {
}
}
console.log(tokens);
return tokens;
};

View File

@@ -1,22 +0,0 @@
{
"name": "simpleql",
"version": "0.1.0",
"description": "",
"main": "server/server.js",
"directories": {
"doc": "docs"
},
"scripts": {
"start": "pm2 start server/server.js",
"restart": "pm2 restart server/server.js",
"stop": "pm2 stop server/server.js",
"list": "pm2 list",
"node": "node server/server.js"
},
"author": "Kayne Ruse",
"license": "ISC",
"dependencies": {
"express": "^4.17.1",
"pm2": "^4.4.1"
}
}

View File

@@ -1,6 +1,6 @@
{
"name": "simpleql",
"version": "0.1.0",
"name": "test-server",
"version": "0.2.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@@ -322,9 +322,9 @@
"integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI="
},
"ast-types": {
"version": "0.14.1",
"resolved": "https://registry.npmjs.org/ast-types/-/ast-types-0.14.1.tgz",
"integrity": "sha512-pfSiukbt23P1qMhNnsozLzhMLBs7EEeXqPyvPmnuZM+RMfwfqwDbSVKYflgGuVI7/VehR4oMks0igzdNAg4VeQ==",
"version": "0.14.2",
"resolved": "https://registry.npmjs.org/ast-types/-/ast-types-0.14.2.tgz",
"integrity": "sha512-O0yuUDnZeQDL+ncNGlJ78BiO4jnYI3bvMsD5prT0/nsgijG/LpNBIr63gTjVTNsiGkgQhiyCShTgxt8oXOrklA==",
"requires": {
"tslib": "^2.0.1"
}
@@ -538,9 +538,9 @@
"integrity": "sha512-vKQ9DTQPN1FLYiiEEOQ6IBGFqvjCa5rSK3cWMy/Nespm5d/x3dGFT9UBZnkLxCwua/IXBi2TYnwTEpsOvhC4UQ=="
},
"dayjs": {
"version": "1.8.35",
"resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.8.35.tgz",
"integrity": "sha512-isAbIEenO4ilm6f8cpqvgjZCsuerDAz2Kb7ri201AiNn58aqXuaLJEnCtfIMdCvERZHNGRY5lDMTr/jdAnKSWQ=="
"version": "1.8.36",
"resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.8.36.tgz",
"integrity": "sha512-3VmRXEtw7RZKAf+4Tv1Ym9AGeo8r8+CjDi26x+7SYQil1UqtqdaokhzoEJohqlzt0m5kacJSDhJQkG/LWhpRBw=="
},
"debug": {
"version": "2.6.9",
@@ -1018,16 +1018,16 @@
"integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg=="
},
"mime-db": {
"version": "1.43.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.43.0.tgz",
"integrity": "sha512-+5dsGEEovYbT8UY9yD7eE4XTc4UwJ1jBYlgaQQF38ENsKR3wj/8q8RFZrF9WIZpB2V1ArTVFUva8sAul1NzRzQ=="
"version": "1.44.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.44.0.tgz",
"integrity": "sha512-/NOTfLrsPBVeH7YtFPgsVWveuL+4SjjYxaQ1xtM1KMFj7HdxlBlxeyNLzhyJVx7r4rZGJAZ/6lkKCitSc/Nmpg=="
},
"mime-types": {
"version": "2.1.26",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.26.tgz",
"integrity": "sha512-01paPWYgLrkqAyrlDorC1uDwl2p3qZT7yl806vW7DvDoxwXi46jsjFbg+WdwotBIk6/MbEhO/dh5aZ5sNj/dWQ==",
"version": "2.1.27",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.27.tgz",
"integrity": "sha512-JIhqnCasI9yD+SsmkquHBxTSEuZdQX5BuQnS2Vc7puQQQ+8yiP5AY5uWhpdv4YL4VM5c6iliiYWPgJ/nJQLp7w==",
"requires": {
"mime-db": "1.43.0"
"mime-db": "1.44.0"
}
},
"minimatch": {
@@ -1049,9 +1049,9 @@
"integrity": "sha1-EUyUlnPiqKNenTV4hSeqN7Z52is="
},
"moment": {
"version": "2.27.0",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.27.0.tgz",
"integrity": "sha512-al0MUK7cpIcglMv3YF13qSgdAIqxHTO7brRtaz3DlSULbqfazqkc5kEjNrLDOM7fsjshoFIihnU8snrP7zUvhQ=="
"version": "2.28.0",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.28.0.tgz",
"integrity": "sha512-Z5KOjYmnHyd/ukynmFd/WwyXHd7L4J9vTI/nn5Ap9AVUgaAE15VvQ9MOGmJJygEUklupqIrFnor/tjTwRU+tQw=="
},
"moment-timezone": {
"version": "0.5.31",
@@ -1665,9 +1665,9 @@
}
},
"systeminformation": {
"version": "4.27.3",
"resolved": "https://registry.npmjs.org/systeminformation/-/systeminformation-4.27.3.tgz",
"integrity": "sha512-0Nc8AYEK818h7FI+bbe/kj7xXsMD5zOHvO9alUqQH/G4MHXu5tHQfWqC/bzWOk4JtoQPhnyLgxMYncDA2eeSBw==",
"version": "4.27.5",
"resolved": "https://registry.npmjs.org/systeminformation/-/systeminformation-4.27.5.tgz",
"integrity": "sha512-EysogxKqREk54ZYDEFcsCODv8GymKZcyiSfegYit8dKhPjzuQr+KX4GFHjssWjYrWFEIM2bYNsFrZX5eufeAXg==",
"optional": true
},
"thunkify": {

19
test-server/package.json Normal file
View File

@@ -0,0 +1,19 @@
{
"name": "test-server",
"version": "0.2.0",
"description": "",
"main": "server.js",
"scripts": {
"start": "pm2 start server.js",
"restart": "pm2 restart server.js",
"stop": "pm2 stop server.js",
"list": "pm2 list",
"node": "node server.js"
},
"author": "Kayne Ruse",
"license": "ISC",
"dependencies": {
"express": "^4.17.1",
"pm2": "^4.4.1"
}
}

View File

@@ -8,13 +8,13 @@ app.use(bodyParser.text());
//test the library
const schema = require('./schema.js');
const handler = require('./handler.js');
const simpleQL = require('./simpleQL');
const sineQL = require('../index.js');
const simple = simpleQL(schema, handler);
const sine = sineQL(schema, handler);
//open the end
app.post('/simpleql', async (req, res) => {
const [code, result] = await simple(req.body);
const [code, result] = await sine(req.body);
res.status(code).send(result);
});