@sugo/body-parser-form-data-multipart
Middleware for parsing form-data, www-form-urlencoded or multipart type requests
How to install
npm install --save @sugo/body-parser-form-data-multipart
SuGoFormDataMultipartBodyParser
Builds the middleware. Receives formidable form options
Example - Node Http Server
import { getMiddleware, IRequest } from '@sugo/body-parser-form-data-multipart';
const parseBody = getMiddleware();
const server = http.createServer(async (req: IRequest, res: http.ServerResponse) => {
await parseBody(req, res);
res.writeHead(200, headers);
res.end(JSON.stringify(req.body));
});
Example - SuGo Server
import { createServer, SuGoRequest, SuGoResponse } from '@sugo/server';
import { getMiddleware, IRequest } from '@sugo/body-parser-form-data-multipart';
const server = createServer((req: SuGoRequest, res: SuGoResponse) => {
res.writeHead(200, headers);
res.end(JSON.stringify(req.body ? req.body : {}));
}).useMiddleware(getMiddleware());