-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* docs: 📝 Update README.md Add shields, update information, add logo for both light and dark theme. * fix: 🐛 Use picture tag https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#specifying-the-theme-an-image-is-shown-to * fix: 📝 Add new line * feat: ✨ Improve order for serving static files, implement remote version check, fix env banner API response Improve serving static files by updating the order of the hlapp's loading pattern, this enables serving static files that have naming collision with hlambda's example: favicon.ico, add remote version check via github API, fix env banner boolean flags, update example metadata * feat: ✨ Update UI Update image to contain new UI files * fix: 🎨 Update example metadata Update metadata example to match yaml syntax * fix: 🐛 Remove duplicate shields in README.md * fix: 🐛 Add .env to .dockerignore, update defaults in constants Add .env to .dockerignore, update defaults in constants.js, update new version to beta.4, add output for environment, added file upload to editor * feat: 🚀 Add new UI to the core * feat: 🚀 Add support for socket.io, update metadata example, add metadata history Add support for socket.io, update metadata example including socket.io example, add metadata history and timestamps. * feat: 🚀 Update UI to v0.0.7 Update Console UI to v0.0.7 * fix: 🐛 Fixes Return valid content for metadata-history * feat: 🚀 Update UI, update CHANGELOG.md * feat: 🎨 Added support for JSON output, prepare code for next minor version release Added support for JSON output to stdout, added new env variable JSON_STDOUT default:false, bugfixes * feat: 🎨 Update Core Console UI * fix: 🐛 Fix metadata reset Fix metadata reset, fix typo * fix: 🐛 Fix logged text, fix swagger's custom js * fix: 🐛 Fix metadata example copy location
- Loading branch information
Showing
44 changed files
with
633 additions
and
96 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
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
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
Empty file.
Empty file.
Empty file.
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,21 @@ | ||
import { createErrorDescriptor } from 'hlambda'; | ||
|
||
// --- START SAFE TO EDIT --- | ||
|
||
export const errorsGroupName = 'demo-hlambda-app'; | ||
|
||
export const errors = { | ||
FUNCTIONALITY_NOT_IMPLEMENTED: { | ||
message: | ||
'Specific functionality is still in development. (It should be available soon, thank you for understanding.)', | ||
}, | ||
SOMETHING_WENT_TERRIBLY_WRONG: { | ||
message: 'Description of an error message...', | ||
}, | ||
}; | ||
|
||
// --- STOP SAFE TO EDIT --- | ||
|
||
export const ed = createErrorDescriptor(errors, errorsGroupName); | ||
|
||
export default errors; |
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,14 @@ | ||
import 'colors'; | ||
|
||
const hasuraRequestLogger = (req, res, next) => { | ||
console.log(`[${req.originalUrl}] Request hit!`); | ||
// -------------------------------------------------------------------------------- | ||
// Get variables | ||
console.log('This is what we received from Hasura when calling the hook'); | ||
console.log(req.body); | ||
console.log(Array(80 + 1).join('-')); | ||
// -------------------------------------------------------------------------------- | ||
next(); | ||
}; | ||
|
||
export default hasuraRequestLogger; |
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,24 @@ | ||
# Defines if the app is enabled or not, disabled apps are skipped from importing | ||
enabled: true | ||
# # Defines if we want to use namespace or not | ||
# use_namespace: true # NOT IN USE! | ||
# # Define the namespace name | ||
# namespace_name: 'demo_app' # NOT IN USE! | ||
# Custom environment variables override for our app | ||
env: | ||
HASURA_GRAPHQL_API_ENDPOINT: "http://graphql-engine:8099/v1/graphql" | ||
HASURA_GRAPHQL_ADMIN_SECRET: "hlambda-test" | ||
HLAMBDA_DISABLE_CONSOLE: "false" | ||
|
||
#HLAMBDA_ENABLE_ENVIRONMENT_BANNER: "true" | ||
#HLAMBDA_ENVIRONMENT_BANNER_NAME: "Local Hlambda Demo Development" | ||
#HLAMBDA_ENVIRONMENT_BANNER_MESSAGE: "Hello Hlambda Env Banner!" | ||
#HLAMBDA_ENABLE_ENVIRONMENT_BANNER_COLOR: "#eeFF22" | ||
|
||
#JSON_STDOUT: true | ||
|
||
envForce: | ||
HASURA_GRAPHQL_API_ENDPOINT: "http://graphql-engine:8099/v1/graphql" | ||
HASURA_GRAPHQL_ADMIN_SECRET: "real-password" | ||
SPECIAL_PASSWORD: "value-from-env" | ||
HLAMBDA_DISABLE_CONSOLE: "false" |
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,34 @@ | ||
import express from 'express'; | ||
import asyncHandler from 'express-async-handler'; | ||
|
||
import { DateTime } from 'luxon'; | ||
|
||
import hasuraRequestLogger from './hasura-request-logger.js'; | ||
|
||
import errors from './errors.demo.js'; | ||
|
||
import requestTimeLogger from '../../../src/utils/requestTimer.js'; | ||
|
||
// Create express router | ||
const router = express.Router(); | ||
|
||
router.use('/demo*', hasuraRequestLogger); | ||
router.use('/demo*', requestTimeLogger); | ||
|
||
router.get( | ||
'/demo', | ||
asyncHandler((req, res) => { | ||
res.send(`Demo app works: ${DateTime.now()} ${process.env.SPECIAL_PASSWORD}`); | ||
}) | ||
); | ||
|
||
router.get( | ||
'/demo-error', | ||
asyncHandler((req, res) => { | ||
// res.send(`Demo app works: ${DateTime.now()} ${process.env.SPECIAL_PASSWORD}`); | ||
throw new Error(errors.SOMETHING_WENT_TERRIBLY_WRONG); | ||
// res.send(`Demo app works: ${DateTime.now()} ${process.env.SPECIAL_PASSWORD}`); | ||
}) | ||
); | ||
|
||
export default router; |
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,21 @@ | ||
import { createErrorDescriptor } from 'hlambda'; | ||
|
||
// --- START SAFE TO EDIT --- | ||
|
||
export const errorsGroupName = 'example-hasura-app'; | ||
|
||
export const errors = { | ||
FUNCTIONALITY_NOT_IMPLEMENTED: { | ||
message: | ||
'Specific functionality is still in development. (It should be available soon, thank you for understanding.)', | ||
}, | ||
SOMETHING_WENT_TERRIBLY_WRONG: { | ||
message: 'Description of an error message...', | ||
}, | ||
}; | ||
|
||
// --- STOP SAFE TO EDIT --- | ||
|
||
export const ed = createErrorDescriptor(errors, errorsGroupName); | ||
|
||
export default errors; |
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,14 @@ | ||
// import 'colors'; // This is known issue with this package... | ||
|
||
const hasuraRequestLogger = (req, res, next) => { | ||
console.log(`[${req.originalUrl}] Request hit!`); | ||
// -------------------------------------------------------------------------------- | ||
// Get variables | ||
console.log('This is what we received from Hasura when calling the hook'); | ||
console.log(req.body); | ||
console.log(Array(80 + 1).join('-')); | ||
// -------------------------------------------------------------------------------- | ||
next(); | ||
}; | ||
|
||
export default hasuraRequestLogger; |
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,4 @@ | ||
env: | ||
APP_VERSION: "v1.0.0" | ||
envForce: | ||
APP_VERSION: "v1.0.0" |
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,26 @@ | ||
import express from 'express'; | ||
import asyncHandler from 'express-async-handler'; | ||
|
||
// Import our custom request logger | ||
import hasuraRequestLogger from './hasura-request-logger.js'; | ||
|
||
// Import our errors definition | ||
import errors from './errors.demo.js'; | ||
|
||
// Create express router | ||
const router = express.Router(); | ||
|
||
router.use('/hasura-*', hasuraRequestLogger); | ||
|
||
router.post( | ||
'/hasura-version', | ||
asyncHandler((req, res) => { | ||
console.log(`${process.env.APP_VERSION}`); | ||
throw new Error(errors.SOMETHING_WENT_TERRIBLY_WRONG); | ||
// res.json({ | ||
// version: `${process.env.APP_VERSION}`, | ||
// }); | ||
}) | ||
); | ||
|
||
export default router; |
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,17 @@ | ||
import { createErrorDescriptor } from 'hlambda'; | ||
|
||
// --- START SAFE TO EDIT --- | ||
|
||
export const errorsGroupName = 'socket-io'; | ||
|
||
export const errors = { | ||
SOCKET_SERVER_NOT_RUNNING: { | ||
message: 'Socket server is not available.', | ||
}, | ||
}; | ||
|
||
// --- STOP SAFE TO EDIT --- | ||
|
||
export const ed = createErrorDescriptor(errors, errorsGroupName); | ||
|
||
export default errors; |
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,60 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Socket.IO chat</title> | ||
<style> | ||
html { | ||
color-scheme: dark !important; | ||
} | ||
html, body { | ||
background-color:#181a1b; | ||
} | ||
body { margin: 0; padding-bottom: 3rem; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; } | ||
body { | ||
border-color: #736b5e; | ||
color: #e8e6e3; | ||
} | ||
|
||
#form { background: rgba(0, 0, 0, 0.15); padding: 0.25rem; position: fixed; bottom: 0; left: 0; right: 0; display: flex; height: 3rem; box-sizing: border-box; backdrop-filter: blur(10px); } | ||
#input { border: none; padding: 0 1rem; flex-grow: 1; border-radius: 2rem; margin: 0.25rem; } | ||
#input:focus { outline: none; } | ||
#form > button { background: #333; border: none; padding: 0 1rem; margin: 0.25rem; border-radius: 3px; outline: none; color: #fff; } | ||
|
||
|
||
#messages { list-style-type: none; margin: 0; padding: 0; } | ||
#messages > li { padding: 0.5rem 1rem; } | ||
#messages > li:nth-child(odd) { background: #212425; } | ||
</style> | ||
</head> | ||
<body> | ||
<ul id="messages"></ul> | ||
<form id="form" action=""> | ||
<input id="input" autocomplete="off" /><button>Send</button> | ||
</form> | ||
<!-- <script src="https://cdn.socket.io/4.5.0/socket.io.min.js" integrity="sha384-7EyYLQZgWBi67fBtVxw60/OWl1kjsfrPFcaU0pp0nAh+i8FD068QogUvg85Ewy1k" crossorigin="anonymous"></script> --> | ||
<script src="/socket.io/socket.io.js"></script> | ||
|
||
<script> | ||
var socket = io(); | ||
|
||
var messages = document.getElementById('messages'); | ||
var form = document.getElementById('form'); | ||
var input = document.getElementById('input'); | ||
|
||
form.addEventListener('submit', function(e) { | ||
e.preventDefault(); | ||
if (input.value) { | ||
socket.emit('chat message', input.value); | ||
input.value = ''; | ||
} | ||
}); | ||
|
||
socket.on('chat message', function(msg) { | ||
var item = document.createElement('li'); | ||
item.textContent = msg; | ||
messages.appendChild(item); | ||
window.scrollTo(0, document.body.scrollHeight); | ||
}); | ||
</script> | ||
</body> | ||
</html> |
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,71 @@ | ||
/* eslint-disable no-underscore-dangle */ | ||
import { fileURLToPath } from 'url'; | ||
import path, { dirname } from 'path'; | ||
|
||
import express from 'express'; | ||
import asyncHandler from 'express-async-handler'; | ||
import { Server } from 'socket.io'; | ||
|
||
import { executeWithAdminRights, getEnvValue, isEnvTrue } from 'hlambda'; | ||
|
||
// // Define constants & errors | ||
// import constants from "./../../constants/constants.index.js"; | ||
import errors from './errors.socket-io.js'; | ||
|
||
const __filename = fileURLToPath(import.meta.url); | ||
const __dirname = dirname(__filename); | ||
|
||
// Pull from global scope hlambdaEventEmitter | ||
const { hlambdaEventEmitter } = global; | ||
// -------------------------------------------------------------------------------- | ||
// Why do we do this? | ||
// Hlambda emitts event 'server-ready' when the server starts to listen. In that event we have reference to server instance. | ||
// Socket.io needs that server instance reference to work. This is not necessary if you want to run another server on different port. | ||
let io; | ||
const attachSocketIoServer = async (server) => { | ||
// const server = await global.HLAMBDA_SERVER_INSTANCE; | ||
// const io = new Server(server, {}); | ||
io = new Server(server, {}); // We want to use io from router. | ||
|
||
io.on('connection', (socket) => { | ||
console.log('Socket connected!'); | ||
|
||
socket.on('chat message', (msg) => { | ||
io.emit('chat message', msg); | ||
}); | ||
|
||
socket.on('disconnect', () => { | ||
console.log('Socket disconnected!'); | ||
}); | ||
}); | ||
}; | ||
|
||
// Listen for event. | ||
hlambdaEventEmitter.on('server-ready', (server) => { | ||
console.log(`[hlambdaEventEmitter] 'server-ready' event occurred!`.green); | ||
attachSocketIoServer(server); | ||
}); | ||
// -------------------------------------------------------------------------------- | ||
|
||
// Create express router | ||
const router = express.Router(); | ||
|
||
// Example of serving static files on route /io | ||
router.use('/io', express.static(path.resolve(__dirname, './public'))); | ||
|
||
router.get( | ||
'/io/msg', | ||
asyncHandler((req, res) => { | ||
if (typeof io === 'undefined') { | ||
throw new Error(errors.SOCKET_SERVER_NOT_RUNNING); | ||
} | ||
|
||
io.emit('chat message', 'Server message!'); | ||
|
||
res.json({ | ||
done: true, | ||
}); | ||
}) | ||
); | ||
|
||
export default router; |
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,4 @@ | ||
#Uncomment this for static serving. | ||
|
||
#envForce: | ||
# HLAMBDA_DISABLE_INITIAL_ROUTE_REDIRECT: true |
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 @@ | ||
x |
Oops, something went wrong.