mirror of
https://github.com/Ratstail91/sineQL.git
synced 2025-11-29 02:34:28 +11:00
25 lines
602 B
JavaScript
25 lines
602 B
JavaScript
//express for testing
|
|
const express = require('express');
|
|
const bodyParser = require('body-parser');
|
|
const app = express();
|
|
|
|
app.use(bodyParser.text());
|
|
|
|
//test the library
|
|
const schema = require('./schema.js');
|
|
const handler = require('./handler.js');
|
|
const sineQL = require('../index.js');
|
|
|
|
const sine = sineQL(schema, handler);
|
|
|
|
//open the end
|
|
app.post('/simpleql', async (req, res) => {
|
|
const [code, result] = await sine(req.body);
|
|
res.status(code).send(result);
|
|
});
|
|
|
|
//startup
|
|
app.listen(process.env.WEB_PORT || 3100, err => {
|
|
console.log(`listening to *:${process.env.WEB_PORT || 3100}`);
|
|
});
|