mirror of
https://github.com/Ratstail91/sineQL.git
synced 2025-11-29 02:34:28 +11:00
28 lines
673 B
JavaScript
28 lines
673 B
JavaScript
//express for testing
|
|
const express = require('express');
|
|
const cors = require('cors');
|
|
const bodyParser = require('body-parser');
|
|
|
|
const app = express();
|
|
|
|
app.use(cors());
|
|
app.use(bodyParser.text());
|
|
|
|
//test the library
|
|
const schema = require('./schema.js');
|
|
const handler = require('./handler.js');
|
|
const sineQL = require('../source/index.js');
|
|
|
|
const sine = sineQL(schema, handler, { debug: false });
|
|
|
|
//open the end
|
|
app.post('/sineql', 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}`);
|
|
});
|