mirror of
https://github.com/Ratstail91/sineQL.git
synced 2025-11-29 02:34:28 +11:00
Adjusted handler API
This commit is contained in:
27
test-server-pokemon/server.js
Normal file
27
test-server-pokemon/server.js
Normal file
@@ -0,0 +1,27 @@
|
||||
//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: true });
|
||||
|
||||
//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}`);
|
||||
});
|
||||
Reference in New Issue
Block a user