@iannisz/node-cms
Advanced tools
Comparing version 0.0.23 to 0.0.24
{ | ||
"name": "@iannisz/node-cms", | ||
"version": "0.0.23", | ||
"version": "0.0.24", | ||
"description": "Node CMS", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -53,3 +53,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () { | ||
var socket, reqBody, files_1, files_1_1, file, fileMeta, stream, reader, chunk, end, e_1_1; | ||
var socket, files_1, files_1_1, file, stream, reader, chunk, e_1_1; | ||
var e_1, _a; | ||
@@ -76,4 +76,4 @@ return __generator(this, function (_b) { | ||
}); | ||
reqBody = stringToUint8Array(JSON.stringify(body)); | ||
socket.emit('data', reqBody.buffer); | ||
// Send body | ||
socket.emit('body', body); | ||
_b.label = 1; | ||
@@ -87,3 +87,4 @@ case 1: | ||
file = files_1_1.value; | ||
fileMeta = stringToUint8Array("\n--------------------file\n" + JSON.stringify({ | ||
// Send file meta | ||
socket.emit('file meta', { | ||
name: file.name, | ||
@@ -93,4 +94,3 @@ lastModified: file.lastModified, | ||
type: file.type | ||
}) + "\n"); | ||
socket.emit('data', fileMeta.buffer); | ||
}); | ||
stream = file.stream(); | ||
@@ -105,7 +105,5 @@ reader = stream.getReader(); | ||
if (!chunk.done) { | ||
socket.emit('data', chunk.value.buffer); | ||
socket.emit('file chunk', chunk.value.buffer); | ||
} | ||
else { | ||
end = stringToUint8Array("\n--------------------end"); | ||
socket.emit('data', end.buffer); | ||
return [3 /*break*/, 5]; | ||
@@ -128,3 +126,6 @@ } | ||
return [7 /*endfinally*/]; | ||
case 9: return [2 /*return*/]; | ||
case 9: | ||
// End the request | ||
socket.emit('end'); | ||
return [2 /*return*/]; | ||
} | ||
@@ -131,0 +132,0 @@ }); |
@@ -30,21 +30,17 @@ interface SocketResponse { | ||
// Create body | ||
// Send body | ||
const reqBody = stringToUint8Array(JSON.stringify(body)) | ||
socket.emit('body', body) | ||
socket.emit('data', reqBody.buffer) | ||
// Send files | ||
// Create file metas | ||
for (let file of files) { | ||
const fileMeta = stringToUint8Array( | ||
`\n--------------------file\n${ JSON.stringify({ | ||
name: file.name, | ||
lastModified: file.lastModified, | ||
size: file.size, | ||
type: file.type | ||
}) }\n` | ||
) | ||
// Send file meta | ||
socket.emit('data', fileMeta.buffer) | ||
socket.emit('file meta', { | ||
name: file.name, | ||
lastModified: file.lastModified, | ||
size: file.size, | ||
type: file.type | ||
}) | ||
@@ -58,6 +54,4 @@ const stream: ReadableStream<Uint8Array> = file.stream() | ||
if (!chunk.done) { | ||
socket.emit('data', chunk.value.buffer) | ||
socket.emit('file chunk', chunk.value.buffer) | ||
} else { | ||
const end = stringToUint8Array(`\n--------------------end`) | ||
socket.emit('data', end.buffer) | ||
break | ||
@@ -67,2 +61,6 @@ } | ||
} | ||
// End the request | ||
socket.emit('end') | ||
}) | ||
@@ -69,0 +67,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
358444
8080