Skip to content

Commit

Permalink
QA: indent ts as js
Browse files Browse the repository at this point in the history
  • Loading branch information
f3l1x authored and Milan Felix Šulc committed Aug 20, 2019
1 parent fad0b36 commit bbb1eaa
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 87 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Expand Up @@ -13,7 +13,7 @@ indent_style = tab
indent_size = tab
tab_width = 4

[*.{js}]
[*.{js,ts}]
indent_style = space
indent_size = 2

Expand Down
2 changes: 1 addition & 1 deletion packages/php-lib/v7.2/src/types.d.ts
@@ -1,3 +1,3 @@
interface Files {
[filePath: string]: import('@now/build-utils').File;
[filePath: string]: import('@now/build-utils').File;
}
2 changes: 1 addition & 1 deletion packages/php-lib/v7.3/src/types.d.ts
@@ -1,3 +1,3 @@
interface Files {
[filePath: string]: import('@now/build-utils').File;
[filePath: string]: import('@now/build-utils').File;
}
2 changes: 1 addition & 1 deletion packages/php-lib/v7.4/src/types.d.ts
@@ -1,3 +1,3 @@
interface Files {
[filePath: string]: import('@now/build-utils').File;
[filePath: string]: import('@now/build-utils').File;
}
82 changes: 41 additions & 41 deletions packages/php/src/launchers/helpers.ts
Expand Up @@ -6,62 +6,62 @@ export const getPhpDir = (): string => pathJoin(process.env.LAMBDA_TASK_ROOT ||
export const isDev = (): boolean => process.env.NOW_PHP_DEV === '1';

export function normalizeEvent(event: Event): AwsRequest {
if (event.Action === 'Invoke') {
const invokeEvent = JSON.parse(event.body);
if (event.Action === 'Invoke') {
const invokeEvent = JSON.parse(event.body);

const {
method, path, host, headers = {}, encoding,
}: InvokedEvent = invokeEvent;

let { body } = invokeEvent;
const {
method, path, host, headers = {}, encoding,
}: InvokedEvent = invokeEvent;

if (body) {
if (encoding === 'base64') {
body = Buffer.from(body, encoding);
} else if (encoding === undefined) {
body = Buffer.from(body);
} else {
throw new Error(`Unsupported encoding: ${encoding}`);
}
}
let { body } = invokeEvent;

return {
method,
path,
host,
headers,
body,
};
if (body) {
if (encoding === 'base64') {
body = Buffer.from(body, encoding);
} else if (encoding === undefined) {
body = Buffer.from(body);
} else {
throw new Error(`Unsupported encoding: ${encoding}`);
}
}

const {
httpMethod: method, path, host, headers = {}, body,
} = event;

return {
method,
path,
host,
headers,
body,
method,
path,
host,
headers,
body,
};
}

const {
httpMethod: method, path, host, headers = {}, body,
} = event;

return {
method,
path,
host,
headers,
body,
};
}

export async function transformFromAwsRequest({
method, path, host, headers, body,
method, path, host, headers, body,
}: AwsRequest): Promise<PhpInput> {
const { pathname, search } = urlParse(path);
const { pathname, search } = urlParse(path);

const filename = pathJoin(
getUserDir(),
process.env.NOW_ENTRYPOINT || pathname || '',
);
const filename = pathJoin(
getUserDir(),
process.env.NOW_ENTRYPOINT || pathname || '',
);

const uri = pathname + (search || '');
const uri = pathname + (search || '');

return { filename, path, uri, host, method, headers, body };
return { filename, path, uri, host, method, headers, body };
}

export function transformToAwsResponse({ statusCode, headers, body }: PhpOutput): AwsResponse {
return { statusCode, headers, body: body.toString('base64'), encoding: 'base64' };
return { statusCode, headers, body: body.toString('base64'), encoding: 'base64' };
}
84 changes: 42 additions & 42 deletions packages/php/src/types.d.ts
@@ -1,82 +1,82 @@
type Headers = { [k: string]: string | string[] | undefined };

interface Files {
[filePath: string]: import('@now/build-utils').File;
[filePath: string]: import('@now/build-utils').File;
}

interface MetaOptions {
meta: import('@now/build-utils').Meta;
meta: import('@now/build-utils').Meta;
}

interface AwsRequest {
method: string,
path: string,
host: string,
headers: Headers,
body: string,
method: string,
path: string,
host: string,
headers: Headers,
body: string,
}

interface AwsResponse {
statusCode: number,
headers: Headers,
body: string,
encoding?: string
statusCode: number,
headers: Headers,
body: string,
encoding?: string
}

interface Event {
Action: string,
body: string,
httpMethod: string,
path: string,
host: string,
headers: Headers,
encoding: string | undefined | null,
Action: string,
body: string,
httpMethod: string,
path: string,
host: string,
headers: Headers,
encoding: string | undefined | null,
}

interface InvokedEvent {
method: string,
path: string,
host: string,
headers: Headers,
encoding: string | undefined | null,
method: string,
path: string,
host: string,
headers: Headers,
encoding: string | undefined | null,
}

interface CgiInput {
filename: string,
path: string,
host: string,
method: string,
headers: Headers,
filename: string,
path: string,
host: string,
method: string,
headers: Headers,
}

interface PhpInput {
filename: string,
path: string,
uri: string,
host: string,
method: string,
headers: Headers,
body: string,
filename: string,
path: string,
uri: string,
host: string,
method: string,
headers: Headers,
body: string,
}

interface PhpOutput {
statusCode: number,
headers: Headers,
body: Buffer,
statusCode: number,
headers: Headers,
body: Buffer,
}

interface CgiHeaders {
[k: string]: string,
[k: string]: string,
}

interface CgiRequest {
env: Env,
env: Env,
}

interface Env {
[k: string]: any,
[k: string]: any,
}

interface PhpIni {
[k: string]: any,
[k: string]: any,
}

0 comments on commit bbb1eaa

Please sign in to comment.