Skip to content

Commit 4baa1bc

Browse files
committed
feat: 🚀 Updates for release v0.3.0
1 parent f21d770 commit 4baa1bc

File tree

119 files changed

+15786
-1385
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+15786
-1385
lines changed

.env.example

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,18 @@ JSON_STDOUT="false"
1414
# Sets up logging level: critical, normal, verbose
1515
LOG_LEVELS="critical,normal,verbose"
1616

17+
# Constant reference in code: ENV_LOG_HISTORY_BUFFER_SIZE | Default value: 255
18+
# Sets up logging history buffer size. It is a max length of the history buffer, every record is the call of log function, that can contain multi-line text. (Default: 255)
19+
LOG_HISTORY_BUFFER_SIZE="255"
20+
21+
# Constant reference in code: ENV_EXPRESS_REQUEST_LOG_HISTORY_BUFFER_SIZE | Default value: 255
22+
# Sets up logging history buffer size. It is a max length of the history buffer, every record is the record of the request. (Default: 255)
23+
EXPRESS_REQUEST_LOG_HISTORY_BUFFER_SIZE="255"
24+
25+
# Constant reference in code: ENV_ENABLE_REQUEST_HISTORY | Default value: false
26+
# Enables request history, useful if you want to log the last n requests and be able to replay the request. (Default: false)
27+
ENABLE_REQUEST_HISTORY="false"
28+
1729
# Constant reference in code: ENV_SERVER_PORT | Default value: 1331
1830
# Server port on which express app will be hosted
1931
SERVER_PORT="1331"

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
# Release 0.3.0
2+
3+
- Added zero downtime reload.
4+
- Added fully featured vscode for editing metadata in Console UI
5+
- Added pre-installed Hlambda extension to custom vscode build.
6+
- Added pre-installed Hasura extension to custom vscode build.
7+
- Added pre-installed Color-Vision extension to custom vscode build.
8+
- Updated Console UI. Home page now shows both logs and Swagger UI.
9+
- Added support for saving request history, added replay option for the requests saved in request history.
10+
- Replaced terminal with vscode pseudo terminal.
11+
- Updated to new Hlambda logo.
12+
- Updated favicon.
13+
114
# Release 0.2.0
215

316
- Updated Console UI (Logs: Auto scroll snap, Metadata: Action history dates)

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,19 @@
77

88
## What is Hlambda (/hlæmdə/) [Hyper Lambda]
99

10-
Hlambda is ECMAScript meta API service. That means that it offers simple ways to deploy ECMAScript code to local or remote servers.
10+
Hlambda is ECMAScript meta API service. It offers simple ways to deploy ECMAScript code to local or remote servers.
1111

1212
<a href="https://hub.docker.com/r/hlambda/hlambda-core" title="Docker Image">
1313

1414
<picture>
15-
<source media="(prefers-color-scheme: dark)" srcset="https://www.hlambda.io/assets/hlambda-logo-light.png">
16-
<source media="(prefers-color-scheme: light)" srcset="https://www.hlambda.io/assets/hlambda-logo-dark.png">
17-
<img alt="Hlambda Banner" src="https://www.hlambda.io/assets/hlambda-logo-dark.png">
15+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/hlambda/hlambda-core/master/public/static/images/hlambda-logo-banner-light-blue.png">
16+
<source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/hlambda/hlambda-core/master/public/static/images/hlambda-logo-banner-blue.png">
17+
<img alt="Hlambda Banner" src="https://raw.githubusercontent.com/hlambda/hlambda-core/master/public/static/images/hlambda-logo-banner-blue.png">
1818
</picture>
1919

2020
</a>
2121

22-
It is the implementation of the idea to load your ECMAScript code as configuration (metadata). With Hlambda you can easily create a microservice that can load arbitrary code configuration.
22+
It is the implementation of the idea to load your ECMAScript code as configuration (metadata). With Hlambda you can easily create a microservice that can load arbitrary code configurations.
2323

2424
The main use case was to implement a stateless REST microservice that will run Hasura custom actions in a separate container, containing any custom business logic.
2525

docker/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Hlambda is easy to manage, meta ECMAScript API server, with console UI and CLI t
1515

1616
Your ECMAScript metadata payload is the configuration of the (Hyper Lambda) Hlambda Server.
1717

18-
![Hlambda Banner](https://www.hlambda.io/assets/hlambda-logo-dark.png)
18+
![Hlambda Banner](https://raw.githubusercontent.com/hlambda/hlambda-core/master/public/static/images/hlambda-logo-banner-blue.png)
1919

2020
# How to use this image
2121

metadata/apps/auth/routes/router.auth.js

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,17 @@
11
import express from 'express';
22
import asyncHandler from 'express-async-handler';
3-
43
import { DateTime } from 'luxon';
5-
64
import hasuraRequestLogger from './../hasura-request-logger.js';
7-
85
import errors from './../errors.demo.js';
96

10-
// Create express router
117
const router = express.Router();
128

139
router.use('/hook/auth*', hasuraRequestLogger);
1410

1511
router.get(
1612
'/hook/auth',
17-
asyncHandler((req, res) => {
18-
res.send(`Demo app works: ${DateTime.now()} ${process.env.SPECIAL_PASSWORD}`);
19-
})
20-
);
21-
22-
router.get(
23-
'/hook/auth-error',
24-
asyncHandler((req, res) => {
25-
// res.send(`Demo app works: ${DateTime.now()} ${process.env.SPECIAL_PASSWORD}`);
26-
throw new Error(errors.SOMETHING_WENT_TERRIBLY_WRONG);
27-
// res.send(`Demo app works: ${DateTime.now()} ${process.env.SPECIAL_PASSWORD}`);
13+
asyncHandler(async (req, res) => {
14+
res.send(`Demo auth hook works: ${DateTime.now()} ${process.env.SPECIAL_PASSWORD}`);
2815
})
2916
);
3017

metadata/apps/auth/routes/router.cookies.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import express from 'express';
22
import asyncHandler from 'express-async-handler';
3-
43
import cookieParser from 'cookie-parser';
5-
64
import errors from './../errors.demo.js';
75

86
// Create express router
@@ -12,15 +10,15 @@ const router = express.Router();
1210

1311
router.get(
1412
'/cookie/set',
15-
asyncHandler((req, res) => {
13+
asyncHandler(async (req, res) => {
1614
res.cookie('demo-jwt-token', 'token ey...', { maxAge: 10800 });
1715
res.send(`Demo token set!`);
1816
})
1917
);
2018

2119
router.get(
2220
'/cookie/get',
23-
asyncHandler((req, res) => {
21+
asyncHandler(async (req, res) => {
2422
console.log('Cookies: ', req.cookies);
2523
res.send(JSON.stringify(req.cookies, null, 2));
2624
})
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
// Uncomment this file to test how Hlambda handles bad code with errors.
3+
4+
import express from 'express';
5+
import asyncHandler from 'express-async-handler';
6+
7+
// Create express router
8+
const router = express.Router();
9+
10+
// This app is intentionally wrong, fix it your self to see that even broken scripts won't kill hlambda container
11+
12+
router.get(
13+
'/await-but-not-async',
14+
asyncHandler(
15+
// async
16+
(req, res) => {
17+
await (async () => {})()
18+
res.send(`Be careful that your resolver really is async when you use await. There will be no stacktrace`);
19+
})
20+
);
21+
22+
export default router;
23+
24+
*/

metadata/apps/bad-app/router.auth.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ zzzzz;
1616
1717
router.get(
1818
'/share-dependency',
19-
asyncHandler((req, res) => {
19+
asyncHandler(async (req, res) => {
2020
res.send(`Prototype login works: ${DateTime.now()}`);
2121
})
2222
);
Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,40 @@
1-
# Defines if the app is enabled or not, disabled apps are skipped from importing
2-
enabled: true
3-
# # Defines if we want to use namespace or not
4-
# use_namespace: true # NOT IN USE!
5-
# # Define the namespace name
6-
# namespace_name: 'demo_app' # NOT IN USE!
7-
# Custom environment variables override for our app
81
env:
9-
HASURA_GRAPHQL_API_ENDPOINT: "http://graphql-engine:8099/v1/graphql"
10-
HASURA_GRAPHQL_ADMIN_SECRET: "hlambda-test"
11-
HLAMBDA_DISABLE_CONSOLE: "false"
12-
2+
HASURA_GRAPHQL_API_ENDPOINT: 'http://graphql-engine:8099/v1/graphql'
3+
HASURA_GRAPHQL_ADMIN_SECRET: 'hlambda-test'
4+
HLAMBDA_DISABLE_CONSOLE: 'false'
5+
ENABLE_REQUEST_HISTORY: 'true'
6+
137
#HLAMBDA_ENABLE_ENVIRONMENT_BANNER: "true"
148
#HLAMBDA_ENVIRONMENT_BANNER_NAME: "Local Hlambda Demo Development"
159
#HLAMBDA_ENVIRONMENT_BANNER_MESSAGE: "Hello Hlambda Env Banner!"
1610
#HLAMBDA_ENABLE_ENVIRONMENT_BANNER_COLOR: "#eeFF22"
1711

1812
#JSON_STDOUT: true
1913

14+
# Custom environment variables override for our app
2015
envForce:
21-
HASURA_GRAPHQL_API_ENDPOINT: "http://graphql-engine:8099/v1/graphql"
22-
HASURA_GRAPHQL_ADMIN_SECRET: "real-password"
23-
SPECIAL_PASSWORD: "value-from-env"
24-
HLAMBDA_DISABLE_CONSOLE: "false"
16+
HASURA_GRAPHQL_API_ENDPOINT: 'http://graphql-engine:8099/v1/graphql'
17+
HASURA_GRAPHQL_ADMIN_SECRET: 'real-password'
18+
SPECIAL_PASSWORD: 'value-from-env'
19+
HLAMBDA_DISABLE_CONSOLE: 'false'
20+
21+
# Consider that cwd for the script is ./metadata/ , also we suggest that you do not deploy ts as metadata, only js and do transpilation before metadata apply.
22+
# But if you want you can slow down the reload time and await for scripts to run after every reload.
23+
#postReloadScripts:
24+
# - npm install --only=production
25+
# - npx tsc --module ES2020 ./apps/example-demo-app/router.demo-ts.ts
26+
27+
# If used routers and entrypoints are skipped from importing
28+
#ignoreRouters: './*' # use `true` for all
29+
#ignoreEntrypoints: './*' # use `true` for all
30+
31+
# Defines if the app is enabled or not, disabled apps are not applied (configuration is ignored)
32+
#enabled: false # default true
33+
34+
# --- Proposals ---
35+
36+
# # Defines if we want to use namespace or not
37+
# use_namespace: true # NOT IN USE!
38+
39+
# # Define the namespace name
40+
# namespace_name: 'demo_app' # NOT IN USE!
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3+
return new (P || (P = Promise))(function (resolve, reject) {
4+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7+
step((generator = generator.apply(thisArg, _arguments || [])).next());
8+
});
9+
};
10+
var __generator = (this && this.__generator) || function (thisArg, body) {
11+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13+
function verb(n) { return function (v) { return step([n, v]); }; }
14+
function step(op) {
15+
if (f) throw new TypeError("Generator is already executing.");
16+
while (_) try {
17+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18+
if (y = 0, t) op = [op[0] & 2, t.value];
19+
switch (op[0]) {
20+
case 0: case 1: t = op; break;
21+
case 4: _.label++; return { value: op[1], done: false };
22+
case 5: _.label++; y = op[1]; op = [0]; continue;
23+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
24+
default:
25+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29+
if (t[2]) _.ops.pop();
30+
_.trys.pop(); continue;
31+
}
32+
op = body.call(thisArg, _);
33+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35+
}
36+
};
37+
import express from 'express';
38+
import asyncHandler from 'express-async-handler';
39+
import { DateTime } from 'luxon'; // Import third-party modules (Don't forget to install them)
40+
import hasuraRequestLogger from './hasura-request-logger.js';
41+
import requestTimeLogger from '../../../src/utils/requestTimer.js';
42+
// Create express router
43+
var router = express.Router();
44+
var stringValue = '3';
45+
('#fefefe');
46+
// Add middlewares
47+
router.use('/ts*', hasuraRequestLogger);
48+
router.use('/ts*', requestTimeLogger);
49+
// Create route
50+
router.get('/ts', asyncHandler(function (req, res) { return __awaiter(void 0, void 0, void 0, function () {
51+
return __generator(this, function (_a) {
52+
// console.log(stringValue.toFixed(8));
53+
res.send("ts app works: ".concat(DateTime.now(), " ").concat(process.env.SPECIAL_PASSWORD));
54+
return [2 /*return*/];
55+
});
56+
}); }));
57+
// // To releax the TSC when throwing errors.__ERROR__
58+
// interface ErrorConstructor {
59+
// new (message?: string | { message: string }): Error;
60+
// (message?: string | { message: string }): Error;
61+
// readonly prototype: Error;
62+
// }
63+
// declare var Error: ErrorConstructor;
64+
// router.get(
65+
// '/ts-error',
66+
// asyncHandler(async (req, res) => {
67+
// // res.send(`Demo app works: ${DateTime.now()} ${process.env.SPECIAL_PASSWORD}`);
68+
// throw new Error(errors.SOMETHING_WENT_TERRIBLY_WRONG);
69+
// // res.send(`Demo app works: ${DateTime.now()} ${process.env.SPECIAL_PASSWORD}`);
70+
// })
71+
// );
72+
export default router;

0 commit comments

Comments
 (0)