Skip to content

Commit 97bd327

Browse files
committed
pleasing the linter gods
1 parent 587c542 commit 97bd327

File tree

1 file changed

+29
-29
lines changed

1 file changed

+29
-29
lines changed

compiler/src/dump/extract-routes.ts

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import {
2525
} from '../model/metamodel'
2626

2727
// use npm run dump-routes --prefix compiler -- --debug to print the Go debug map
28-
const debugTestRoutes = argv.debug ?? false
28+
const debugRoutes: boolean = argv.debug ?? false
2929
const outputPath = argv.output ?? join(__dirname, '..', '..', '..', 'output', 'schema', 'routes.go')
3030
const V8SchemaUrl = join(__dirname, '..', '..', '..', 'output', 'schema', 'schema.json')
3131
const V7SchemaUrl = 'https://raw.githubusercontent.com/elastic/elasticsearch-specification/7.17/output/schema/schema.json'
@@ -290,26 +290,26 @@ async function extractRoutesFromFiles (outPath: string): Promise<void> {
290290
const v7Spec = await v7Schema.text()
291291

292292
const serverlessSpec = await readFile(
293-
serverlessSchemaUrl,
294-
{ encoding: 'utf8' }
293+
serverlessSchemaUrl,
294+
{ encoding: 'utf8' }
295295
)
296296

297297
const versions = new Map<string, string>()
298-
versions.set("7", v7Spec)
299-
versions.set("8", v8Spec)
300-
versions.set("serverless", serverlessSpec)
298+
versions.set('7', v7Spec)
299+
versions.set('8', v8Spec)
300+
versions.set('serverless', serverlessSpec)
301301

302302
const forest = new Forest()
303303

304304
versions.forEach(function (spec, version) {
305305
const inputModel = JSON.parse(spec)
306-
if (debugTestRoutes) {
307-
debug_test_routes(version, inputModel)
306+
if (debugRoutes) {
307+
debugTestRoutes(version, inputModel)
308308
}
309309
const routes = extractRoutes(inputModel)
310310
forest.byVersion.set(version, routes)
311311
})
312-
forest.byVersion.set("0", defaultRoutes())
312+
forest.byVersion.set('0', defaultRoutes())
313313

314314
const str = serializeForest(forest)
315315

@@ -562,30 +562,30 @@ function defaultRoutes (): Trees {
562562
return t
563563
}
564564

565-
function debug_test_routes(version: string, inputModel: Model) {
566-
console.log(version);
565+
function debugTestRoutes (version: string, inputModel: Model): void {
566+
console.log(version)
567567

568-
let output = new Map<string, Map<string, string>[]>();
568+
const output = new Map<string, Array<Map<string, string>>>()
569569

570-
for (const endpoint of inputModel.endpoints) {
571-
for (const url of endpoint.urls) {
572-
for (const method of url.methods) {
573-
if (!output.has(method)) {
574-
output.set(method, [])
575-
}
576-
let newPath = url.path.replace(new RegExp("\{|\}", 'g'), "")
577-
output.get(method)?.push(new Map<string, string>([[newPath, endpoint.name]]));
578-
}
570+
for (const endpoint of inputModel.endpoints) {
571+
for (const url of endpoint.urls) {
572+
for (const method of url.methods) {
573+
if (!output.has(method)) {
574+
output.set(method, [])
579575
}
576+
const newPath = url.path.replace(/\{|\}/g, '')
577+
output.get(method)?.push(new Map<string, string>([[newPath, endpoint.name]]))
578+
}
580579
}
580+
}
581581

582-
output.forEach((urls, method) => {
583-
console.log('"%s": {', method)
584-
urls.forEach((path) => {
585-
path.forEach((name, path) => {
586-
console.log('{"%s", "%s"},', path, name)
587-
})
588-
})
589-
console.log("},")
582+
output.forEach((urls, method) => {
583+
console.log('"%s": {', method)
584+
urls.forEach((path) => {
585+
path.forEach((name, path) => {
586+
console.log('{"%s", "%s"},', path, name)
587+
})
590588
})
589+
console.log('},')
590+
})
591591
}

0 commit comments

Comments
 (0)