chore: prettier changes

This commit is contained in:
AP 2019-11-30 11:50:38 +01:00
parent d045d5be6c
commit af2ef16c10
3 changed files with 94 additions and 96 deletions

View file

@ -1,5 +1,5 @@
{
"printWidth": 100,
"printWidth": 80,
"trailingComma": "all",
"tabWidth": 4,
"semi": true,

View file

@ -1,15 +1,13 @@
import base64url from "base64url";
import { authenticatedLndGrpc } from "ln-service";
import base64url from 'base64url';
import { authenticatedLndGrpc } from 'ln-service';
export const getIp = (req: any) => {
if (!req || !req.headers) {
return "";
return '';
}
const forwarded = req.headers["x-forwarded-for"];
const before = forwarded
? forwarded.split(/, /)[0]
: req.connection.remoteAddress;
const ip = process.env.NODE_ENV === "development" ? "1.2.3.4" : before;
const forwarded = req.headers['x-forwarded-for'];
const before = forwarded ? forwarded.split(/, /)[0] : req.connection.remoteAddress;
const ip = process.env.NODE_ENV === 'development' ? '1.2.3.4' : before;
return ip;
};
@ -18,10 +16,10 @@ export const getBase64CertfromDerFormat = (url: string) => {
const base64 = base64url.toBase64(url);
const prefix = "-----BEGIN CERTIFICATE-----\n";
const postfix = "-----END CERTIFICATE-----";
const prefix = '-----BEGIN CERTIFICATE-----\n';
const postfix = '-----END CERTIFICATE-----';
const pem = base64.match(/.{0,64}/g) || [];
const pemString = pem.join("\n");
const pemString = pem.join('\n');
const pemComplete = prefix + pemString + postfix;
const pemText = base64url.encode(pemComplete);
@ -32,8 +30,8 @@ export const getAuthLnd = (auth: string) => {
const url = new URL(auth);
// console.log(url);
const encodedCert = url.searchParams.get("cert") || "";
const encodedMacaroon = url.searchParams.get("macaroon") || "";
const encodedCert = url.searchParams.get('cert') || '';
const encodedMacaroon = url.searchParams.get('macaroon') || '';
const socket = url.host;
const cert = getBase64CertfromDerFormat(encodedCert);
@ -45,11 +43,11 @@ export const getAuthLnd = (auth: string) => {
// console.log(encodedCert);
const params =
encodedCert !== ""
encodedCert !== ''
? {
cert,
macaroon,
socket
socket,
}
: { macaroon, socket };