-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
133 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,11 @@ | ||
build: | ||
wasm-pack --version && \ | ||
wasm-pack build --target web --out-dir pkg-web/ | ||
wasm-pack build --target web --out-dir pkg-web/ | ||
|
||
container-build: | ||
wasm-pack --version && \ | ||
wasm-pack build --target nodejs --out-dir pkg-node/ && \ | ||
docker build -f docker/Dockerfile . -t partiql-team/partiql-playground | ||
|
||
container-run: | ||
docker run -d -p 8000:8000 partiql-team/partiql-playground |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules | ||
npm-debug.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
FROM node:18 | ||
# Create app directory | ||
WORKDIR /usr/src/app | ||
|
||
# Install app dependencies | ||
# A wildcard is used to ensure both package.json AND package-lock.json are copied | ||
# where available (npm@5+) | ||
COPY ./docker/package*.json ./ | ||
COPY ./pkg-node ./ | ||
|
||
RUN npm install | ||
# If you are building your code for production | ||
RUN npm ci --only=production | ||
|
||
# Bundle app source | ||
COPY . . | ||
|
||
EXPOSE 8080 | ||
|
||
CMD [ "node", "docker/server.ts" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"name": "partiql-playground", | ||
"version": "0.1.0", | ||
"description": "PartiQL Playground", | ||
"main": "server.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/partiql-lang-rust/partiql-playground.git" | ||
}, | ||
"keywords": [ | ||
"PartiQL", | ||
"Playground" | ||
], | ||
"author": "[email protected]", | ||
"license": "Apache-2.0", | ||
"bugs": { | ||
"url": "https://github.com/partiql-lang-rust/partiql-playground/issues" | ||
}, | ||
"homepage": "https://github.com/partiql-lang-rust/partiql-playground#readme", | ||
"dependencies": { | ||
"body-parser": "^1.20.0", | ||
"express": "^4.18.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
const express = require('express'); | ||
const bodyParser = require("body-parser"); | ||
const router = express.Router(); | ||
const partiql = require('../pkg-node/partiql_playground'); | ||
|
||
const app = express(); | ||
const port = 8000; | ||
|
||
|
||
app.use(bodyParser.urlencoded({ extended: false })); | ||
app.use(bodyParser.json()); | ||
|
||
router.post('/parse', (req, res) => { | ||
res.status(200) | ||
.json(JSON.stringify(JSON | ||
.parse(partiql.parse_as_json(req.body.query) | ||
) | ||
)); | ||
}); | ||
|
||
router.post('/explain', (req, res) => { | ||
res.status(200) | ||
.json(JSON.stringify(JSON | ||
.parse(partiql.explain_as_json(req.body.query) | ||
) | ||
)); | ||
}); | ||
|
||
router.post('/eval', (req, res) => { | ||
res.status(200) | ||
.json(JSON.stringify(JSON | ||
.parse(partiql.eval_as_json(req.body.query, req.body.env)) | ||
)); | ||
}); | ||
|
||
app.use("/", router); | ||
|
||
app.listen(port, () => { | ||
console.log(`Now listening on port ${port}`); | ||
}); |