Skip to content

Commit

Permalink
better types
Browse files Browse the repository at this point in the history
  • Loading branch information
mlibre committed May 25, 2024
1 parent 883d52f commit 8011106
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 27 deletions.
6 changes: 0 additions & 6 deletions dist/API/app.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/API/app.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
"node": ">=20"
},
"scripts": {
"3000": "tsx ./src/API/app.ts --host 'http://127.0.0.1:3000' --nodes 'http://127.0.0.1:3001' --dbPath './assets/db/' --minerKeysFile './assets/keys/miner.json' --name 'GoodChain'",
"3001": "tsx ./src/API/app.ts --host 'http://127.0.0.1:3001' --nodes 'http://127.0.0.1:3000' --dbPath './assets/db/' --minerKeysFile './assets/keys/miner.json' --name 'GoodChain'",
"3002": "tsx ./src/API/app.ts --host 'http://127.0.0.1:3002' --nodes 'http://127.0.0.1:3000' --dbPath './assets/db/' --minerKeysFile './assets/keys/miner.json' --name 'GoodChain'",
"build": "rm -r dist && tsc",
"watch": "rm -r dist && tsc --watch",
"dev": "tsc && nodemon ./src/API/app.ts",
"start": "tsx ./src/API/app.ts",
"startjs": "node ./src/API/app.js",
"3000": "tsx ./src/API/app.ts --host 'http://127.0.0.1:3000' --nodes 'http://127.0.0.1:3001' --dbPath './assets/db/' --minerKeysFile './assets/keys/miner.json' --name 'GoodChain'",
"3001": "tsx ./src/API/app.ts --host 'http://127.0.0.1:3001' --nodes 'http://127.0.0.1:3000' --dbPath './assets/db/' --minerKeysFile './assets/keys/miner.json' --name 'GoodChain'",
"3002": "tsx ./src/API/app.ts --host 'http://127.0.0.1:3002' --nodes 'http://127.0.0.1:3000' --dbPath './assets/db/' --minerKeysFile './assets/keys/miner.json' --name 'GoodChain'",
"test": "vitest run",
"test-ui": "vitest --ui"
},
Expand Down Expand Up @@ -69,4 +69,4 @@
"start": "tsc"
}
}
}
}
10 changes: 1 addition & 9 deletions src/API/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function onListening ()
console.log( "Listening on", ( server.address() as AddressInfo ).address, ( server.address() as AddressInfo ).port );
}

function onError ( error: AnyError )
function onError ( error: NodeJS.ErrnoException )
{
if ( error.syscall !== "listen" )
{
Expand All @@ -51,17 +51,9 @@ function onError ( error: AnyError )
{
case "EACCES":
console.error( `${hostPort} requires elevated privileges` );
if ( !process.exit( 1 ) )
{
console.error( "Cant Exit" );
}
break;
case "EADDRINUSE":
console.error( `${hostPort} is already in use` );
if ( !process.exit( 1 ) )
{
console.error( "Cant Exit" );
}
break;
default:
throw error;
Expand Down
6 changes: 0 additions & 6 deletions src/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,4 @@ interface SimpleError
message?: string;
stack?: string;
[key: string]: SimpleError;
}

interface AnyError extends Error
{
[x: string]: string;
[key: string]: string;
}
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"skipLibCheck": true,
"sourceMap": true,
"useUnknownInCatchVariables": true,
"noUnusedLocals": true,
"noUnusedLocals": true
// "isolatedModules": true
},
// "include": [
Expand Down

0 comments on commit 8011106

Please sign in to comment.