Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| abc1cef7c2 | |||
| 766ff96137 |
41
bin/upload-jmespath
Executable file
41
bin/upload-jmespath
Executable file
@@ -0,0 +1,41 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
API_URL="https://jmespath-playground.koszewscy.waw.pl"
|
||||
JSON_FILE="-"
|
||||
|
||||
function usage() {
|
||||
echo "Usage: $0 [--api-url <url>] [--json-file <file>]"
|
||||
exit 1
|
||||
}
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
--api-url)
|
||||
API_URL="$2"
|
||||
shift 2
|
||||
;;
|
||||
--json-file)
|
||||
JSON_FILE="$2"
|
||||
shift 2
|
||||
;;
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo "ERROR: Unknown argument: $1"
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Send the POST request
|
||||
curl -s -X POST \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Accept: application/json" \
|
||||
--data @${JSON_FILE} \
|
||||
"$API_URL/api/v1/upload"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "jmespath-playground",
|
||||
"version": "1.1.6",
|
||||
"version": "1.1.7",
|
||||
"description": "A React-based web application for testing JMESPath expressions against JSON data",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
||||
@@ -51,7 +51,13 @@ function createApp() {
|
||||
|
||||
app.get('/api/v1/sample', (req, res) => {
|
||||
try {
|
||||
res.json(sampleData);
|
||||
const dataToReturn = sampleData;
|
||||
|
||||
// Security: Clear the sample data after it's retrieved (one-time use)
|
||||
sampleData = null;
|
||||
console.log('📤 Sample data retrieved and cleared from server memory');
|
||||
|
||||
res.json(dataToReturn);
|
||||
} catch (error) {
|
||||
res.status(500).json({ error: 'Failed to retrieve sample data' });
|
||||
}
|
||||
|
||||
24
src/App.js
24
src/App.js
@@ -54,22 +54,30 @@ function App() {
|
||||
localStorage.setItem('theme', theme);
|
||||
}, [theme]);
|
||||
|
||||
// API polling for state changes
|
||||
// API polling for state changes and initial sample data load
|
||||
useEffect(() => {
|
||||
// Initial state load
|
||||
const loadInitialState = async () => {
|
||||
// Initial load: get both state and sample data
|
||||
const loadInitialData = async () => {
|
||||
try {
|
||||
const response = await fetch('/api/v1/state');
|
||||
if (response.ok) {
|
||||
const data = await response.json();
|
||||
setCurrentStateGuid(data.state);
|
||||
// Load sample data first
|
||||
const sampleResponse = await fetch('/api/v1/sample');
|
||||
if (sampleResponse.ok) {
|
||||
const sampleData = await sampleResponse.json();
|
||||
setJsonData(JSON.stringify(sampleData, null, 2));
|
||||
}
|
||||
|
||||
// Then load state GUID
|
||||
const stateResponse = await fetch('/api/v1/state');
|
||||
if (stateResponse.ok) {
|
||||
const stateData = await stateResponse.json();
|
||||
setCurrentStateGuid(stateData.state);
|
||||
}
|
||||
} catch (error) {
|
||||
console.debug('API not available:', error);
|
||||
}
|
||||
};
|
||||
|
||||
loadInitialState();
|
||||
loadInitialData();
|
||||
|
||||
// Poll for state changes every 3 seconds
|
||||
const interval = setInterval(async () => {
|
||||
|
||||
Reference in New Issue
Block a user