Skip to content

Commit 2b9ba3f

Browse files
Merge pull request #1255 from opencomponents/noPropertyAccessFromIndexSignature
[INTERNAL] enable noPropertyAccessFromIndexSignature option and fix problems
2 parents 9cc4067 + 1542ed0 commit 2b9ba3f

13 files changed

+37
-37
lines changed

src/registry/app-start.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export default function appStart(
2828

2929
logger.log(
3030
colors.yellow(
31-
`Connecting to library: ${options.storage.options.bucket}/${options.storage.options.componentsDir}`
31+
`Connecting to library: ${options.storage.options['bucket']}/${options.storage.options.componentsDir}`
3232
)
3333
);
3434

src/registry/domain/options-sanitiser.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export default function optionsSanitiser(input: Input): Config {
6868
options.customHeadersToSkipOnWeakVersion || []
6969
).map(s => s.toLowerCase());
7070

71-
options.port = Number(process.env.PORT || options.port);
71+
options.port = Number(process.env['PORT'] || options.port);
7272
options.timeout = options.timeout || 1000 * 60 * 2;
7373
options.keepAliveTimeout =
7474
options.keepAliveTimeout || DEFAULT_NODE_KEEPALIVE_MS;
@@ -85,22 +85,22 @@ export default function optionsSanitiser(input: Input): Config {
8585
}
8686

8787
if (options.refreshInterval && options.storage) {
88-
options.storage.options.refreshInterval = options.refreshInterval;
88+
options.storage.options['refreshInterval'] = options.refreshInterval;
8989
}
9090

9191
if (options.verbosity && options.storage) {
92-
options.storage.options.verbosity = options.verbosity;
92+
options.storage.options['verbosity'] = options.verbosity;
9393
}
9494

9595
if (
9696
options.storage &&
9797
options.storage.options &&
98-
options.storage.options.path
98+
options.storage.options['path']
9999
) {
100-
options.storage.options.path =
101-
options.storage.options.path.indexOf('http') === 0
102-
? options.storage.options.path
103-
: `https:${options.storage.options.path}`;
100+
options.storage.options['path'] =
101+
options.storage.options['path'].indexOf('http') === 0
102+
? options.storage.options['path']
103+
: `https:${options.storage.options['path']}`;
104104
}
105105

106106
if (!options.env) {

src/registry/domain/repository.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ export default function repository(conf: Config): Repository {
225225
getComponentPath(componentName: string, componentVersion: string) {
226226
const prefix = conf.local
227227
? conf.baseUrl
228-
: `${options!.path}${options!.componentsDir}/`;
228+
: `${options!['path']}${options!.componentsDir}/`;
229229
return `${prefix}${componentName}/${componentVersion}/`;
230230
},
231231
getComponents(callback: Callback<string[]>) {
@@ -284,14 +284,14 @@ export default function repository(conf: Config): Repository {
284284
);
285285
},
286286
getStaticClientPath: () =>
287-
`${options!.path}${getFilePath(
287+
`${options!['path']}${getFilePath(
288288
'oc-client',
289289
packageInfo.version,
290290
'src/oc-client.min.js'
291291
)}`,
292292

293293
getStaticClientMapPath: () =>
294-
`${options!.path}${getFilePath(
294+
`${options!['path']}${getFilePath(
295295
'oc-client',
296296
packageInfo.version,
297297
'src/oc-client.min.map'

src/registry/domain/validators/registry-configuration.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,10 @@ export default function registryConfiguration(
105105
const cdn = conf.storage.adapter(conf.storage.options);
106106
if (cdn.adapterType === 's3') {
107107
if (
108-
!conf.storage.options.bucket ||
109-
!conf.storage.options.region ||
110-
(conf.storage.options.key && !conf.storage.options.secret) ||
111-
(!conf.storage.options.key && conf.storage.options.secret)
108+
!conf.storage.options['bucket'] ||
109+
!conf.storage.options['region'] ||
110+
(conf.storage.options['key'] && !conf.storage.options['secret']) ||
111+
(!conf.storage.options['key'] && conf.storage.options['secret'])
112112
) {
113113
return returnError(
114114
strings.errors.registry.CONFIGURATION_STORAGE_NOT_VALID(

src/registry/routes/component-info.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ function componentInfo(
8383
} else {
8484
res.status(200).json(
8585
Object.assign(component, {
86-
requestVersion: req.params.componentVersion || ''
86+
requestVersion: req.params['componentVersion'] || ''
8787
})
8888
);
8989
}
@@ -95,8 +95,8 @@ export default function componentInfoRoute(
9595
) {
9696
return function (req: Request, res: Response): void {
9797
repository.getComponent(
98-
req.params.componentName,
99-
req.params.componentVersion,
98+
req.params['componentName'],
99+
req.params['componentVersion'],
100100
(registryError, component) => {
101101
if (registryError && conf.fallbackRegistryUrl) {
102102
return getComponentFallback.getComponentInfo(

src/registry/routes/component-preview.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function componentPreview(
3838
} else {
3939
res.status(200).json(
4040
Object.assign(component, {
41-
requestVersion: req.params.componentVersion || ''
41+
requestVersion: req.params['componentVersion'] || ''
4242
})
4343
);
4444
}
@@ -50,8 +50,8 @@ export default function componentPreviewRoute(
5050
) {
5151
return (req: Request, res: Response): void => {
5252
repository.getComponent(
53-
req.params.componentName,
54-
req.params.componentVersion,
53+
req.params['componentName'],
54+
req.params['componentVersion'],
5555
(registryError, component) => {
5656
if (registryError && conf.fallbackRegistryUrl) {
5757
return getComponentFallback.getComponentPreview(

src/registry/routes/component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ export default function component(
1818
conf: res.conf,
1919
headers: req.headers,
2020
ip: req.ip,
21-
name: req.params.componentName,
21+
name: req.params['componentName'],
2222
parameters: req.query as any,
23-
version: req.params.componentVersion
23+
version: req.params['componentVersion']
2424
},
2525
result => {
2626
if (result.response.error) {

src/registry/routes/helpers/get-component-fallback.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ function getComponentFallbackForViewType(
2727
) {
2828
const path = buildUrl(
2929
{
30-
name: req.params.componentName,
31-
version: req.params.componentVersion
30+
name: req.params['componentName'],
31+
version: req.params['componentVersion']
3232
},
3333
conf.fallbackRegistryUrl
3434
);

src/registry/routes/helpers/get-component.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -236,13 +236,13 @@ export default function getComponent(conf: Config, repository: Repository) {
236236

237237
const parseTemplatesHeader = (t: string) =>
238238
t.split(';').map(t => t.split(',')[0]);
239-
const supportedTemplates = options.headers.templates
240-
? parseTemplatesHeader(options.headers.templates as string)
239+
const supportedTemplates = options.headers['templates']
240+
? parseTemplatesHeader(options.headers['templates'] as string)
241241
: [];
242242

243243
const isTemplateSupportedByClient = Boolean(
244244
isValidClientRequest &&
245-
options.headers.templates &&
245+
options.headers['templates'] &&
246246
(_.includes(
247247
supportedTemplates,
248248
component.oc.files.template.type
@@ -521,7 +521,7 @@ export default function getComponent(conf: Config, repository: Repository) {
521521

522522
try {
523523
vm.runInNewContext(dataProvider.content, context, options);
524-
const processData = context.module.exports.data;
524+
const processData = context.module.exports['data'];
525525
cache.set('file-contents', cacheKey, processData);
526526

527527
domain.on('error', handleError);

src/registry/routes/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ export default function (repository: Repository) {
9696
}),
9797
componentsHistory:
9898
!res.conf.local && getComponentsHistory(details),
99-
q: req.query.q || '',
99+
q: req.query['q'] || '',
100100
stateCounts,
101101
templates: repository.getTemplatesInfo(),
102102
title: 'OpenComponents Registry'

0 commit comments

Comments
 (0)