Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
configureBuckets,
...serverOptions
} = defaults({}, options, S3rver.defaultOptions);
this.serverOptions = serverOptions;
this._configureBuckets = configureBuckets;
this.silent = silent;
this.resetOnClose = resetOnClose;
this.allowMismatchedSignatures = allowMismatchedSignatures;
this.store = this.context.store = new FilesystemStore(directory);
// Log all requests
this.use(loggerMiddleware(this, silent));
try {
// encode object responses as XML
const parser = new xmlParser.j2xParser({
ignoreAttributes: false,
attrNodeName: '@',
tagValueProcessor: a => he.escape(a.toString()),
});
this.use(async (ctx, next) => {
await next();
if (isPlainObject(ctx.body)) {
ctx.type = 'application/xml';
ctx.body =
'\n' + parser.parse(ctx.body);
}
});
// Express mount interop
this.use((ctx, next) => {
ctx.mountPath = ctx.mountPath || ctx.req.baseUrl;
protected async _request(method: string, headers: any, resource: Resource, body?: any): Promise {
headers['date'] = new Date().toUTCString()
const uri = getResourceUri(resource)
// 并不知道设置错误的 content-type 会有什么影响,但是设置了就没错
if (body) {
if (typeof body === 'object' && body.constructor === Object) {
body = new j2xParser({}).parse(CamelCaseObject(body))
headers['content-type'] = 'application/xml;charset=UTF-8'
} else {
headers['content-type'] = mime.getType(uri) || 'application/octet-stream'
}
}
if (body instanceof Buffer || typeof body === 'string') {
headers['content-md5'] = md5sum(body)
headers['content-length'] = headers['content-length'] || body.length
}
const sign = signature(this.options.accessSecret, method, headers, resource)
headers['authorization'] = `NOS ${this.options.accessKey}:${sign}`
return await fetch(url.resolve(this.options.endpoint, uri), {
method,
maxConflicts: -1,
disableSparseFiles: false,
disableTempIndexes: false,
paused: false,
weakHashThresholdPct: 25,
markerName: '.stfolder',
copyOwnershipFromParent: false,
modTimeWindowS: 0
});
}
}
);
console.log(xmlObj.configuration);
const final = (new (require("fast-xml-parser").j2xParser)({
format:true,
ignoreAttributes : false,
})).parse(xmlObj);
console.log(final);
saveIt();
bootProgram(program);
}
* https://www.eclipse.org/legal/epl-v20.html
*
* SPDX-License-Identifier: EPL-2.0
*
* Copyright IBM Corp, 2019
*
*/
"use strict";
import { BundlePart, IBundlePartDataType } from "./BundlePart";
import { IHandlerParameters } from "@brightside/imperative";
import * as parser from "fast-xml-parser";
const serialiser = new parser.j2xParser({ignoreAttributes: false, attributeNamePrefix: ""});
/**
* Interface to represent the manifest data for a CICS Bundle.
*
* @export
* @interface IManifestType
*/
interface IManifestType {
manifest: IManifestContents;
}
/**
* Interface to represent the manifest data contents for CICS Bundle.
*
* @export
* @interface IManifestContents
*/
function toXml(obj, format, mode) {
var param = {
format: format
};
if (mode) {
param = {
format: format,
attrNodeName: "_attrs",
textNodeName: "#text",
cdataTagName: "_cdata"
}
};
return xml = new j2xParser(param).parse(obj);
};
* https://www.eclipse.org/legal/epl-v20.html
*
* SPDX-License-Identifier: EPL-2.0
*
* Copyright IBM Corp, 2019
*
*/
"use strict";
import { BundlePart } from "./BundlePart";
import { TemplateNodejsappProfile } from "./TemplateNodejsappProfile";
import { IHandlerParameters } from "@brightside/imperative";
import * as parser from "fast-xml-parser";
const serialiser = new parser.j2xParser({ignoreAttributes: false, attributeNamePrefix: ""});
/**
* Interface to represent the manifest data for a NODEJSAPP BundlePart.
*
* @export
* @interface INodejsappType
*/
interface INodejsappType {
nodejsapp: INodejsappContents;
}
/**
* Interface to represent the manifest data contents for a NODEJSAPP BundlePart.
*
* @export
* @interface INodejsappContents
function saveIt() {
fs.writeFileSync(
path.join(syncConfigPath, 'config.xml'),
(new (require("fast-xml-parser").j2xParser)({
format:true,
ignoreAttributes : false,
})).parse(xmlObj),
'utf8');
}
import { j2xParser } from 'fast-xml-parser';
import typeIs = require('type-is');
const xmlSerializer = new j2xParser({});
const serializers = [
{
test: (value: string) => !!typeIs.is(value, ['application/json', 'application/*+json']),
serializer: JSON.stringify,
},
{
test: (value: string) => !!typeIs.is(value, ['application/xml', 'application/*+xml']),
serializer: (data: unknown) => (typeof data === 'string' ? data : xmlSerializer.parse({ xml: data })),
},
{
test: (value: string) => !!typeIs.is(value, ['text/*']),
serializer: (data: unknown) => {
if (['string', 'undefined'].includes(typeof data)) {
return data;
}