How to use the body-parser.xml function in body-parser

To help you get started, we’ve selected a few body-parser examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github n8n-io / n8n / packages / cli / src / Server.ts View on Github external
// Make sure that each request has the "parsedUrl" parameter
		this.app.use((req: express.Request, res: express.Response, next: express.NextFunction) => {
			(req as ICustomRequest).parsedUrl = parseUrl(req);
			next();
		});

		// Support application/json type post data
		this.app.use(bodyParser.json({ limit: "16mb", verify: (req, res, buf) => {
			// @ts-ignore
			req.rawBody = buf;
		}}));

		// Support application/xml type post data
		// @ts-ignore
		this.app.use(bodyParser.xml({ limit: "16mb", xmlParseOptions: {
			normalize: true,     // Trim whitespace inside text nodes
			normalizeTags: true, // Transform tags to lowercase
			explicitArray: false // Only put properties in array if length > 1
		  } }));

		// Make sure that Vue history mode works properly
		this.app.use(history({
			rewrites: [
				{
					from: new RegExp(`^\/(rest|healthz|css|js|${this.endpointWebhook}|${this.endpointWebhookTest})\/?.*$`),
					to: (context) => {
						return context.parsedUrl!.pathname!.toString();
					}
				}
			]
		}));
github gaowhen / gon / scaffolding / middleware / index.js View on Github external
if (process.env.NODE_ENV === 'development') {
  viewPath = path.resolve(__dirname, '../view/build/')
}

app.use(compression({
  level: zlib.Z_BEST_COMPRESSION,
}))

// parse application/json
app.use(bodyParser.json())

// parse application/x-www-form-urlencoded
app.use(bodyParser.urlencoded({ extended: false }))

// parse xml
app.use(bodyParser.xml())

app.use((req, res, next) => {
  res.locals.env = process.env.NODE_ENV
  next()
})

app.use('/static/', express.static(staticPath))
app.set('view engine', 'pug')
app.set('views', viewPath)
github contactlab / saray / src / index.js View on Github external
module.exports.port = port;

const apiDataPath = path.resolve(program.path);
module.exports.apiDataPath = apiDataPath;

const dynPath = program.dynpath;
module.exports.dynPath = dynPath;

const timeout = program.timeout;
module.exports.timeout = timeout;

module.exports.endpoint = program.endpoint;
module.exports.preferApi = program.preferApi;

app.use(bodyParser.json());
app.use(bodyParser.xml({
  type: [
    'text/xml',
    'application/xml',
    'application/rss+xml',
    'application/soap+xml'
  ]
}));
app.use(bodyParser.urlencoded({
  extended: true
}));

app.use(corsMiddleware);

const endpointMiddleware = require('./middlewares/endpoint')(
  log,
  module.exports.endpoint,
github xiadd / shorthand / app / app.js View on Github external
const createMenu = require('./libs/wxCustomeMenu');
createMenu();


//引入路由
const weixin = require('./routes/weixin');
const auth = require('./routes/auth');
const userinfo = require('./routes/userinfo');

//app配置
const app = express();
app.use(AV.express());
app.set('views', path.join(__dirname, '../views'));

//解析xml
app.use(bodyParser.xml({
  limit: '1MB',
  xmlParseOptions: {
    normalize: true,
    normalizeTags: true,
    explicitArray: false
  }
}));

//启用nunjucks模板
app.engine('html', nunjucks.render);
app.set('view engine', 'html');

//启用路由
app.use('/wechat', weixin);
app.use(auth);
app.use(userinfo);

body-parser

Node.js body parsing middleware

MIT
Latest version published 1 year ago

Package Health Score

76 / 100
Full package analysis