balda-js 0.0.44 → 0.0.46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.cjs +20 -34
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +22 -8
- package/lib/index.d.ts +22 -8
- package/lib/index.js +20 -35
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
package/lib/index.cjs
CHANGED
|
@@ -2224,6 +2224,8 @@ var commandRegistry = CommandRegistry.getInstance();
|
|
|
2224
2224
|
// src/runtime/native_request.ts
|
|
2225
2225
|
var NativeRequest = class extends Request {
|
|
2226
2226
|
};
|
|
2227
|
+
|
|
2228
|
+
// src/server/http/request.ts
|
|
2227
2229
|
var Request2 = class _Request extends NativeRequest {
|
|
2228
2230
|
static fromRequest(request) {
|
|
2229
2231
|
return new _Request(request.url, {
|
|
@@ -2330,7 +2332,10 @@ var Request2 = class _Request extends NativeRequest {
|
|
|
2330
2332
|
*/
|
|
2331
2333
|
files = [];
|
|
2332
2334
|
/**
|
|
2333
|
-
* The parameters of the request.
|
|
2335
|
+
* The parameters of the request. Can be typed with a generic in the Request object
|
|
2336
|
+
* @example
|
|
2337
|
+
* ```ts
|
|
2338
|
+
* Request<{ id: string }>
|
|
2334
2339
|
*/
|
|
2335
2340
|
params = {};
|
|
2336
2341
|
/**
|
|
@@ -2715,7 +2720,8 @@ var Response2 = class {
|
|
|
2715
2720
|
* @param options only affects node and bun environment
|
|
2716
2721
|
*/
|
|
2717
2722
|
file(pathToFile, options) {
|
|
2718
|
-
const
|
|
2723
|
+
const ext = nativePath.extName(pathToFile);
|
|
2724
|
+
const mimeType = getContentType(ext);
|
|
2719
2725
|
this.body = nativeFile.file(pathToFile, options);
|
|
2720
2726
|
this.headers = {
|
|
2721
2727
|
...this.headers,
|
|
@@ -3780,14 +3786,14 @@ var NativeHash = class {
|
|
|
3780
3786
|
const hashBase64 = this.encodeBase64(new Uint8Array(hashBuffer));
|
|
3781
3787
|
return `${saltBase64}:${hashBase64}`;
|
|
3782
3788
|
}
|
|
3783
|
-
async compare(
|
|
3784
|
-
if (!
|
|
3789
|
+
async compare(hash2, data) {
|
|
3790
|
+
if (!hash2 || !data) {
|
|
3785
3791
|
return false;
|
|
3786
3792
|
}
|
|
3787
3793
|
try {
|
|
3788
3794
|
const encoder = new TextEncoder();
|
|
3789
3795
|
const passwordBuffer = encoder.encode(data);
|
|
3790
|
-
const parts =
|
|
3796
|
+
const parts = hash2.split(":");
|
|
3791
3797
|
if (parts.length !== 2) {
|
|
3792
3798
|
throw new Error("Invalid hash format");
|
|
3793
3799
|
}
|
|
@@ -3842,7 +3848,7 @@ var NativeHash = class {
|
|
|
3842
3848
|
return bytes;
|
|
3843
3849
|
}
|
|
3844
3850
|
};
|
|
3845
|
-
var
|
|
3851
|
+
var hash = new NativeHash();
|
|
3846
3852
|
|
|
3847
3853
|
// src/plugins/body_parser/body_parser.ts
|
|
3848
3854
|
var bodyParser = () => {
|
|
@@ -3986,7 +3992,9 @@ var fileParser = (options) => {
|
|
|
3986
3992
|
const indexOfSub = (haystack, needle, from = 0) => {
|
|
3987
3993
|
outer: for (let i = from; i <= haystack.length - needle.length; i++) {
|
|
3988
3994
|
for (let j = 0; j < needle.length; j++) {
|
|
3989
|
-
if (haystack[i + j] !== needle[j])
|
|
3995
|
+
if (haystack[i + j] !== needle[j]) {
|
|
3996
|
+
continue outer;
|
|
3997
|
+
}
|
|
3990
3998
|
}
|
|
3991
3999
|
return i;
|
|
3992
4000
|
}
|
|
@@ -4270,9 +4278,7 @@ var swagger = (globalOptions) => {
|
|
|
4270
4278
|
const uiPath = `${swaggerOptions.path}`;
|
|
4271
4279
|
const jsonPath = `${uiPath}/json`;
|
|
4272
4280
|
let uiContent;
|
|
4273
|
-
if (swaggerOptions.type === "
|
|
4274
|
-
uiContent = generateRedocUI(jsonPath, swaggerOptions);
|
|
4275
|
-
} else if (swaggerOptions.type === "rapidoc") {
|
|
4281
|
+
if (swaggerOptions.type === "rapidoc") {
|
|
4276
4282
|
uiContent = generateRapiDocUI(jsonPath, swaggerOptions);
|
|
4277
4283
|
} else if (swaggerOptions.type === "scalar") {
|
|
4278
4284
|
uiContent = generateScalarUI(jsonPath, swaggerOptions);
|
|
@@ -4571,27 +4577,6 @@ function generateSwaggerUI(specUrl, globalOptions) {
|
|
|
4571
4577
|
</body>
|
|
4572
4578
|
</html>`;
|
|
4573
4579
|
}
|
|
4574
|
-
function generateRedocUI(specUrl, globalOptions) {
|
|
4575
|
-
return `
|
|
4576
|
-
<!DOCTYPE html>
|
|
4577
|
-
<html>
|
|
4578
|
-
<head>
|
|
4579
|
-
<title>${globalOptions.title}</title>
|
|
4580
|
-
<meta charset="utf-8"/>
|
|
4581
|
-
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
4582
|
-
<meta name="description" content="${globalOptions.description}" />
|
|
4583
|
-
<link rel="icon" type="image/png" href="https://redocly.github.io/redoc/favicon.ico">
|
|
4584
|
-
<style>
|
|
4585
|
-
body { margin: 0; padding: 0; }
|
|
4586
|
-
</style>
|
|
4587
|
-
</head>
|
|
4588
|
-
<body>
|
|
4589
|
-
<redoc spec-url="${specUrl}"></redoc>
|
|
4590
|
-
<script src="https://unpkg.com/redoc/bundles/redoc.standalone.js"></script>
|
|
4591
|
-
</body>
|
|
4592
|
-
</html>
|
|
4593
|
-
`;
|
|
4594
|
-
}
|
|
4595
4580
|
function generateRapiDocUI(specUrl, globalOptions) {
|
|
4596
4581
|
return `
|
|
4597
4582
|
<!DOCTYPE html>
|
|
@@ -5070,10 +5055,10 @@ var Server = class {
|
|
|
5070
5055
|
return router.getRoutes() || [];
|
|
5071
5056
|
}
|
|
5072
5057
|
async hash(data) {
|
|
5073
|
-
return
|
|
5058
|
+
return hash.hash(data);
|
|
5074
5059
|
}
|
|
5075
|
-
async compareHash(
|
|
5076
|
-
return
|
|
5060
|
+
async compareHash(hash2, data) {
|
|
5061
|
+
return hash.compare(hash2, data);
|
|
5077
5062
|
}
|
|
5078
5063
|
getEnvironment() {
|
|
5079
5064
|
return this.nativeEnv.getEnvironment();
|
|
@@ -5495,6 +5480,7 @@ exports.fileParser = fileParser;
|
|
|
5495
5480
|
exports.flag = flag;
|
|
5496
5481
|
exports.get = get;
|
|
5497
5482
|
exports.getContentType = getContentType;
|
|
5483
|
+
exports.hash = hash;
|
|
5498
5484
|
exports.helmet = helmet;
|
|
5499
5485
|
exports.json = json;
|
|
5500
5486
|
exports.log = log;
|