Skip to content

Commit ca21de2

Browse files
committed
Style code
1 parent e1be16b commit ca21de2

File tree

7 files changed

+31
-24
lines changed

7 files changed

+31
-24
lines changed

bin/www.ts

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
* Module dependencies.
33
*/
44

5+
import * as debugModule from "debug";
56
import { createApp } from "../src/app";
67
import { closeContext } from "../src/context";
7-
import * as debugModule from "debug";
88
const debug = debugModule("faucet:server");
99
import * as http from "http";
1010

@@ -41,9 +41,12 @@ async function main() {
4141
try {
4242
await new Promise((resolve, reject) => {
4343
server.close((err: any) => {
44-
if (err) { reject(err); return; }
44+
if (err) {
45+
reject(err);
46+
return;
47+
}
4548
resolve();
46-
})
49+
});
4750
});
4851
} catch (err) {
4952
console.error(`Error at closing ${err}`);
@@ -52,8 +55,7 @@ async function main() {
5255
await closeContext(context);
5356
process.exit();
5457
}
55-
})
56-
58+
});
5759
} catch (err) {
5860
console.error(`Error at main ${err}, ${JSON.stringify(err)}`);
5961
}
@@ -89,9 +91,7 @@ function onError(port: any): (error: any) => void {
8991
throw error;
9092
}
9193

92-
const bind = typeof port === "string"
93-
? "Pipe " + port
94-
: "Port " + port;
94+
const bind = typeof port === "string" ? "Pipe " + port : "Port " + port;
9595

9696
// handle specific listen errors with friendly messages
9797
switch (error.code) {
@@ -106,7 +106,7 @@ function onError(port: any): (error: any) => void {
106106
default:
107107
throw error;
108108
}
109-
}
109+
};
110110
}
111111

112112
/**
@@ -116,9 +116,8 @@ function onError(port: any): (error: any) => void {
116116
function onListening(server: any): () => void {
117117
return () => {
118118
const addr = server.address();
119-
const bind = typeof addr === "string"
120-
? "pipe " + addr
121-
: "port " + addr.port;
119+
const bind =
120+
typeof addr === "string" ? "pipe " + addr : "port " + addr.port;
122121
debug("Listening on " + bind);
123-
}
122+
};
124123
}

src/__test__/pign.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Application } from "express";
2-
import { createApp } from "../app";
3-
import { Context, closeContext } from "../context";
42
import * as request from "supertest";
3+
import { createApp } from "../app";
4+
import { closeContext, Context } from "../context";
55

66
let app: Application;
77
let context: Context;

src/app.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import * as createError from "http-errors";
21
import * as express from "express";
3-
import * as path from "path";
2+
import * as createError from "http-errors";
43
import * as logger from "morgan";
4+
import * as path from "path";
55
const morganBody = require("morgan-body");
66

7+
import { Context, createContext } from "./context";
78
import { createRouter as createApiRouter } from "./routes/api";
89
import { createRouter as createPingRouter } from "./routes/ping";
9-
import { createContext, Context } from "./context";
1010

1111
export async function createApp(): Promise<[express.Application, Context]> {
1212
const app = express();

src/context.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export async function createContext(): Promise<Context> {
1010
});
1111
return {
1212
cckey
13-
}
13+
};
1414
}
1515

1616
export function closeContext(context: Context): Promise<void> {

src/routes/api.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ export function createRouter(context: Context) {
1919
router.post("/keys", async (req, res) => {
2020
const { passphrase } = req.body;
2121
const keyType: KeyType = req.body.keyType;
22-
const publicKey = await context.cckey[keyType].createKey({ passphrase });
22+
const publicKey = await context.cckey[keyType].createKey({
23+
passphrase
24+
});
2325
res.json({
2426
success: true,
2527
result: publicKey
@@ -29,7 +31,9 @@ export function createRouter(context: Context) {
2931
router.delete("/keys/:key", async (req, res) => {
3032
const { key } = req.params;
3133
const keyType: KeyType = req.body.keyType;
32-
const result = await context.cckey[keyType].deleteKey({ publicKey: key });
34+
const result = await context.cckey[keyType].deleteKey({
35+
publicKey: key
36+
});
3337
res.json({
3438
success: true,
3539
result
@@ -41,7 +45,11 @@ export function createRouter(context: Context) {
4145
const { key } = req.params;
4246
const { message, passphrase = "" } = req.body;
4347
const keyType: KeyType = req.body.keyType;
44-
const result = await context.cckey[keyType].sign({ publicKey: key, passphrase, message });
48+
const result = await context.cckey[keyType].sign({
49+
publicKey: key,
50+
passphrase,
51+
message
52+
});
4553
res.json({
4654
success: true,
4755
result

src/routes/ping.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export function createRouter(context: Context) {
88
try {
99
await context.cckey.platform.getKeys();
1010
res.json({
11-
success: true,
11+
success: true
1212
});
1313
} catch (err) {
1414
res.json({

testencrypt.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const encrypted = myCrypto.encrypt(privateKey, "password");
77

88
const decrypted = myCrypto.decrypt(encrypted, "password");
99
if (privateKey !== decrypted) {
10-
throw "Decryption failed";
10+
throw new Error("Decryption failed");
1111
} else {
1212
console.log("Decryption success");
1313
}

0 commit comments

Comments
 (0)