Refactor import scripts

This commit is contained in:
Louis Holbrook
2021-02-21 15:41:37 +00:00
parent 1274958493
commit 96b4ad4a72
91 changed files with 5872 additions and 1261 deletions

View File

@@ -1,3 +1,6 @@
* 0.0.7-pending
- Add immutable content
- Add db lock on server
* 0.0.6
- Add server build
* 0.0.5

View File

@@ -1,18 +1,16 @@
{
"name": "cic-client-meta",
"version": "0.0.6",
"version": "0.0.7-alpha.2",
"description": "Signed CRDT metadata graphs for the CIC network",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"test": "mocha -r node_modules/node-localstorage/register -r ts-node/register tests/*.ts",
"build": "node_modules/typescript/bin/tsc -d --outDir dist",
"build": "node_modules/typescript/bin/tsc -d --outDir dist && npm run build-server",
"build-server": "tsc -d --outDir dist-server scripts/server/*.ts",
"pack": "node_modules/typescript/bin/tsc -d --outDir dist && webpack",
"clean": "rm -rf dist"
},
"bin": {
"cic-meta-server": "./dist-server/scripts/server/server.js"
"clean": "rm -rf dist",
"prepare": "npm run build && npm run build-server"
},
"dependencies": {
"@ethereumjs/tx": "^3.0.0-beta.1",

View File

@@ -137,6 +137,7 @@ async function processRequest(req, res) {
console.debug('mode', mod);
let content = '';
let contentType = 'application/json';
console.debug('handling data', data);
let r:any = undefined;
try {
switch (mod) {
@@ -192,14 +193,16 @@ async function processRequest(req, res) {
}
if (content === undefined) {
console.error('empty onctent', data);
res.writeHead(400, {"Content-Type": "text/plain"});
res.end();
return;
}
const responseContentLength = (new TextEncoder().encode(content)).length;
res.writeHead(200, {
"Content-Type": contentType,
"Content-Length": content.length,
"Content-Length": responseContentLength,
});
res.write(content);
res.end();

View File

@@ -2,3 +2,4 @@ export { PGPSigner, PGPKeyStore } from './auth';
export { Envelope, Syncable } from './sync';
export { User } from './assets/user';
export { Phone } from './assets/phone';
export { Config } from './config';