Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 0 additions & 51 deletions package-lock.json

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

2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
"compression": "1.7.4",
"copy-webpack-plugin": "11.0.0",
"express": "4.19.2",
"express-fileupload": "1.4.0",
"file-saver": "^2.0.5",
"follow-redirects": "1.15.6",
"fs-extra": "11.1.1",
Expand Down Expand Up @@ -81,7 +80,6 @@
"@rollup/plugin-url": "^8.0.1",
"@testing-library/react": "14.0.0",
"@tsconfig/docusaurus": "^1.0.5",
"@types/express-fileupload": "1.5.0",
"@types/file-saver": "^2.0.5",
"@types/jest": "^29.4.0",
"@types/node": "18.14.2",
Expand Down
48 changes: 0 additions & 48 deletions packages/wp-now/src/encode-as-multipart.ts

This file was deleted.

17 changes: 1 addition & 16 deletions packages/wp-now/src/start-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@ import { HTTPMethod } from '@php-wasm/universal';
import express from 'express';
import compression from 'compression';
import compressible from 'compressible';
import fileUpload from 'express-fileupload';
import { portFinder } from './port-finder';
import { NodePHP } from '@php-wasm/node';
import { isWebContainer } from '@webcontainer/env';
import startWPNow from './wp-now';
import { output } from './output';
import { addTrailingSlash } from './add-trailing-slash';
import { encodeAsMultipart } from './encode-as-multipart';

const requestBodyToBytes = async (req): Promise<Uint8Array> =>
await new Promise((resolve) => {
Expand Down Expand Up @@ -46,7 +44,6 @@ export async function startServer(
);
}
const app = express();
app.use(fileUpload());
app.use(compression({ filter: shouldCompress }));
app.use(addTrailingSlash('/wp-admin'));
const port = await portFinder.getOpenPort();
Expand All @@ -62,23 +59,11 @@ export async function startServer(
}
}

let body: Uint8Array;
if (
requestHeaders['content-type']?.startsWith(
'multipart/form-data'
)
) {
const multipart = await encodeAsMultipart(req);
body = multipart.bytes;
requestHeaders['content-type'] = multipart.contentType;
} else {
body = await requestBodyToBytes(req);
}
const data = {
url: req.url,
headers: requestHeaders,
method: req.method as HTTPMethod,
body,
body: await requestBodyToBytes(req),
};

if (isWebContainer()) {
Expand Down