Skip to content
Snippets Groups Projects
Commit 9c9e4674 authored by Cédric Moreau's avatar Cédric Moreau
Browse files

[fix] #1037 Migrate server.js

parent bb180336
Branches
Tags
No related merge requests found
...@@ -32,6 +32,7 @@ test/blockchain/*.js ...@@ -32,6 +32,7 @@ test/blockchain/*.js
test/blockchain/*.js.map test/blockchain/*.js.map
test/blockchain/lib/*.js test/blockchain/lib/*.js
test/blockchain/lib/*.js.map test/blockchain/lib/*.js.map
server.js*
app/cli.js* app/cli.js*
app/lib/*.js* app/lib/*.js*
app/lib/blockchain/*.js app/lib/blockchain/*.js
......
...@@ -44,14 +44,17 @@ export class ConfDTO { ...@@ -44,14 +44,17 @@ export class ConfDTO {
public msWindow: number, public msWindow: number,
public sigWindow: number, public sigWindow: number,
public swichOnTimeAheadBy: number, public swichOnTimeAheadBy: number,
public pair: Keypair | null, public pair: Keypair,
public remoteport: number, public remoteport: number,
public remotehost: string, public remotehost: string,
public remoteipv4: string, public remoteipv4: string,
public remoteipv6: string, public remoteipv6: string,
public port: number,
public ipv4: string,
public ipv6: string,
) {} ) {}
static mock() { static mock() {
return new ConfDTO("", "", [], [], 0, 0, 0.6, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, false, 0, false, 0, 0, 0, 0, 0, null, 0, "", "", "") return new ConfDTO("", "", [], [], 0, 0, 0.6, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, false, 0, false, 0, 0, 0, 0, 0, { pub:'', sec:'' }, 0, "", "", "", 0, "", "")
} }
} }
\ No newline at end of file
import {SQLiteDriver} from "../dal/drivers/SQLiteDriver" import {SQLiteDriver} from "../dal/drivers/SQLiteDriver"
import {CFSCore} from "../dal/fileDALs/CFSCore" import {CFSCore} from "../dal/fileDALs/CFSCore"
import {WoTBObject} from "../wot"
const opts = require('optimist').argv; const opts = require('optimist').argv;
const path = require('path'); const path = require('path');
...@@ -29,7 +30,6 @@ const dir = module.exports = { ...@@ -29,7 +30,6 @@ const dir = module.exports = {
getHomeFS: async (isMemory:boolean, theHome:string) => { getHomeFS: async (isMemory:boolean, theHome:string) => {
const home = theHome || dir.getHome(); const home = theHome || dir.getHome();
await someDelayFix();
const params:any = { const params:any = {
home: home home: home
}; };
...@@ -45,10 +45,9 @@ const dir = module.exports = { ...@@ -45,10 +45,9 @@ const dir = module.exports = {
getHomeParams: async (isMemory:boolean, theHome:string) => { getHomeParams: async (isMemory:boolean, theHome:string) => {
const params:any = await dir.getHomeFS(isMemory, theHome) const params:any = await dir.getHomeFS(isMemory, theHome)
const home = params.home; const home = params.home;
await someDelayFix()
if (isMemory) { if (isMemory) {
params.dbf = () => new SQLiteDriver(':memory:'); params.dbf = () => new SQLiteDriver(':memory:');
params.wotb = require('../wot').WoTBObject.memoryInstance(); params.wotb = WoTBObject.memoryInstance();
} else { } else {
const sqlitePath = path.join(home, dir.DUNITER_DB_NAME + '.db'); const sqlitePath = path.join(home, dir.DUNITER_DB_NAME + '.db');
params.dbf = () => new SQLiteDriver(sqlitePath); params.dbf = () => new SQLiteDriver(sqlitePath);
...@@ -57,7 +56,7 @@ const dir = module.exports = { ...@@ -57,7 +56,7 @@ const dir = module.exports = {
if (!existsFile) { if (!existsFile) {
fs.closeSync(fs.openSync(wotbFilePath, 'w')); fs.closeSync(fs.openSync(wotbFilePath, 'w'));
} }
params.wotb = require('../wot').WoTBObject.fileInstance(wotbFilePath); params.wotb = WoTBObject.fileInstance(wotbFilePath);
} }
return params; return params;
}, },
...@@ -67,8 +66,3 @@ const dir = module.exports = { ...@@ -67,8 +66,3 @@ const dir = module.exports = {
return fsHandler.makeTree(''); return fsHandler.makeTree('');
} }
} }
const someDelayFix = () => new Promise((resolve) => {
setTimeout(resolve, 100);
})
...@@ -2,7 +2,7 @@ const wotb = require('wotb'); ...@@ -2,7 +2,7 @@ const wotb = require('wotb');
export interface WoTBInterface { export interface WoTBInterface {
fileInstance: (filepath:string) => any fileInstance: (filepath:string) => any
memoryInstance: (filepath:string) => any memoryInstance: () => any
setVerbose: (verbose:boolean) => void setVerbose: (verbose:boolean) => void
} }
......
...@@ -1013,7 +1013,7 @@ Pius cliquez sur "Find". Vous obtiendrez le résultat suivant : ...@@ -1013,7 +1013,7 @@ Pius cliquez sur "Find". Vous obtiendrez le résultat suivant :
<img src="https://forum.duniter.org/uploads/default/original/1X/48f80f1e07828edab1601f4414f605b995143ddd.png" width="471" height="227"> <img src="https://forum.duniter.org/uploads/default/original/1X/48f80f1e07828edab1601f4414f605b995143ddd.png" width="471" height="227">
Double-cliquez sur le résultat trouvé, et vous serez alors amené au fichier `server.js`, ligne 75. Ajoutez-y un point d'arrêt : Double-cliquez sur le résultat trouvé, et vous serez alors amené au fichier `server.ts`, ligne 75. Ajoutez-y un point d'arrêt :
<img src="https://forum.duniter.org/uploads/default/original/1X/789c7fbb457d3f780316a2cf164ed45f82d0c701.png" width="448" height="94"> <img src="https://forum.duniter.org/uploads/default/original/1X/789c7fbb457d3f780316a2cf164ed45f82d0c701.png" width="448" height="94">
......
...@@ -5,7 +5,7 @@ const path = require('path'); ...@@ -5,7 +5,7 @@ const path = require('path');
const util = require('util'); const util = require('util');
const stream = require('stream'); const stream = require('stream');
const _ = require('underscore'); const _ = require('underscore');
const Server = require('./server'); const Server = require('./server').Server
const directory = require('./app/lib/system/directory'); const directory = require('./app/lib/system/directory');
const constants = require('./app/lib/constants'); const constants = require('./app/lib/constants');
const CLI = require('./app/cli').ExecuteCommand const CLI = require('./app/cli').ExecuteCommand
......
This diff is collapsed.
server.ts 0 → 100644
This diff is collapsed.
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
"noImplicitReturns": true "noImplicitReturns": true
}, },
"include": [ "include": [
"server.ts",
"app", "app",
"bin", "bin",
"test" "test"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment