@adobe/helix-admin-support 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/index.js ADDED
@@ -0,0 +1,21 @@
1
+ /*
2
+ * Copyright 2021 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */
12
+
13
+ export * from './contentbus.js';
14
+ export * from './fetch-config.js';
15
+ export * from './fetch-crontab.js';
16
+ export * from './fetch-fstab.js';
17
+ export * from './fetch-ignore.js';
18
+ export * from './fetch-index.js';
19
+ export * from './fetch-s3.js';
20
+ export * from './fetch-sitemap.js';
21
+ export * from './flatJson2Object.js';
package/src/utils.js ADDED
@@ -0,0 +1,38 @@
1
+ /*
2
+ * Copyright 2021 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */
12
+ import { context as fetchContext, h1, Response } from '@adobe/helix-fetch';
13
+ import { cleanupHeaderValue } from '@adobe/helix-shared-utils';
14
+
15
+ /* c8 ignore next 7 */
16
+ export const { fetch } = process.env.HELIX_FETCH_FORCE_HTTP1
17
+ ? h1({
18
+ userAgent: 'helix-fetch', // static user-agent for recorded tests
19
+ })
20
+ : fetchContext({
21
+ userAgent: 'helix-fetch', // static user-agent for recorded tests
22
+ });
23
+
24
+ /**
25
+ * Generates an error response
26
+ * @param {string} message - error message
27
+ * @param {number} status - error code.
28
+ * @returns {Response} A response object.
29
+ */
30
+ export function error(message, status = 500) {
31
+ return new Response('', {
32
+ status,
33
+ headers: {
34
+ 'Cache-Control': 'no-store, private, must-revalidate',
35
+ 'x-error': cleanupHeaderValue(message),
36
+ },
37
+ });
38
+ }