commit 56f219596211f6f46eac8e7ea4a5c6c7b752c2bf Author: Oliver Date: Fri Dec 23 15:19:37 2022 -0600 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..86620aa --- /dev/null +++ b/.gitignore @@ -0,0 +1,111 @@ +dist/ +data/ +*.toml +!config.template.toml +.vscode/ +src/types/**/*.ts + +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage +*.lcov + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# TypeScript v1 declaration files +typings/ + +# TypeScript cache +*.tsbuildinfo + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Microbundle cache +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env +.env.test + +# parcel-bundler cache (https://parceljs.org/) +.cache + +# Next.js build output +.next + +# Nuxt.js build / generate output +.nuxt +dist + +# Gatsby files +.cache/ +# Comment in the public line in if your project uses Gatsby and *not* Next.js +# https://nextjs.org/blog/next-9-1#public-directory-support +# public + +# vuepress build output +.vuepress/dist + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# TernJS port file +.tern-port diff --git a/README.md b/README.md new file mode 100644 index 0000000..367e62e --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# Hapi-API-Template +An API template based on Hapi. diff --git a/config.template.toml b/config.template.toml new file mode 100644 index 0000000..2f5824d --- /dev/null +++ b/config.template.toml @@ -0,0 +1,5 @@ +[server] +port = 6969 + +[database] +uri = "" \ No newline at end of file diff --git a/generateInterfaces.ts b/generateInterfaces.ts new file mode 100644 index 0000000..95e60e0 --- /dev/null +++ b/generateInterfaces.ts @@ -0,0 +1,31 @@ +/* +This file is a utility used by the build system to generate interfaces from the +Joi schemas, this file should be run by using: + make interfaces +whenever a schema in src/schemas is modified. +*/ +import { convertFromDirectory } from "joi-to-typescript"; + +const defaultOptions = { + indentationChacters: `\t`, + treatDefaultedOptionalAsRequired: true, + typeOutputDirectory: "./src/types", + indexAllToRoot: false, + flattenTree: false, + fileHeader: `/* +This file was automatically generated by joi-to-typescript +Do not modify this file manually +*/` +}; + +// Generate the interfaces from schemas unrelated to any specific endpoint +convertFromDirectory({ + schemaDirectory: `./src/schemas`, + ...defaultOptions, +}); + +// Generate the interfaces for each endpoint +convertFromDirectory({ + schemaDirectory: `./src/endpoints`, + ...defaultOptions, +}); \ No newline at end of file diff --git a/makefile b/makefile new file mode 100644 index 0000000..ff619f6 --- /dev/null +++ b/makefile @@ -0,0 +1,35 @@ +# The node executables to care about +NODE = node +PACKAGE_MANAGER = pnpm + +# The folder that Typescript compiles the Javascript into +OUT_DIR = dist + +#=============================================================================# +# DO NOT CHANGE ANYTHING BELOW THIS LINE +#=============================================================================# + +BIN := $(shell $(PACKAGE_MANAGER) bin) + +.PHONY: $(OUT_DIR) dev prod run rund interfaces + + +$(OUT_DIR): interfaces + tsc --outDir $(OUT_DIR) + +interfaces: + -$(BIN)/ts-node generateInterfaces.ts 2>/dev/null + @$(RM) src/types/index.ts + @echo Finished creating interfaces + +dev: $(OUT_DIR) + NODE_ENV=development $(NODE) $(OUT_DIR)/main.js + +prod: $(OUT_DIR) + NODE_ENV=production $(NODE) $(OUT_DIR)/main.js + +rund: + NODE_ENV=development $(NODE) $(OUT_DIR)/main.js + +run: + NODE_ENV=production $(NODE) $(OUT_DIR)/main.js \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..345b338 --- /dev/null +++ b/package.json @@ -0,0 +1,35 @@ +{ + "name": "hapi-api-template", + "version": "1.0.0", + "description": "", + "main": "dist/main.js", + "scripts": { + "test": "echo \"Use the makefile\" && exit 1" + }, + "keywords": [], + "author": "Oliver Akins", + "license": "UNLICENSED", + "dependencies": { + "@hapi/hapi": "^20.2.2", + "@hapi/inert": "^7.0.0", + "@iarna/toml": "^2.2.5", + "glob": "^8.0.3", + "joi": "^17.6.0", + "module-alias": "^2.2.2", + "path": "^0.12.7", + "tslog": "^3.3.4", + "typescript": "^4.7.4" + }, + "devDependencies": { + "@types/glob": "^7.2.0", + "@types/hapi__hapi": "^20.0.12", + "@types/hapi__inert": "^5.2.3", + "@types/module-alias": "^2.0.1", + "@types/node": "^18.6.4", + "joi-to-typescript": "^4.0.5", + "ts-node": "^10.9.1" + }, + "_moduleAliases": { + "$": "./dist" + } +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml new file mode 100644 index 0000000..1384b26 --- /dev/null +++ b/pnpm-lock.yaml @@ -0,0 +1,618 @@ +lockfileVersion: 5.4 + +specifiers: + '@hapi/hapi': ^20.2.2 + '@hapi/inert': ^7.0.0 + '@iarna/toml': ^2.2.5 + '@types/glob': ^7.2.0 + '@types/hapi__hapi': ^20.0.12 + '@types/hapi__inert': ^5.2.3 + '@types/module-alias': ^2.0.1 + '@types/node': ^18.6.4 + glob: ^8.0.3 + joi: ^17.6.0 + joi-to-typescript: ^4.0.5 + module-alias: ^2.2.2 + path: ^0.12.7 + ts-node: ^10.9.1 + tslog: ^3.3.4 + typescript: ^4.7.4 + +dependencies: + '@hapi/hapi': 20.2.2 + '@hapi/inert': 7.0.0 + '@iarna/toml': 2.2.5 + glob: 8.0.3 + joi: 17.6.0 + module-alias: 2.2.2 + path: 0.12.7 + tslog: 3.3.4 + typescript: 4.7.4 + +devDependencies: + '@types/glob': 7.2.0 + '@types/hapi__hapi': 20.0.12 + '@types/hapi__inert': 5.2.3 + '@types/module-alias': 2.0.1 + '@types/node': 18.6.4 + joi-to-typescript: 4.0.5_joi@17.6.0 + ts-node: 10.9.1_hn66opzbaneygq52jmwjxha6su + +packages: + + /@cspotcode/source-map-support/0.8.1: + resolution: {integrity: sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==} + engines: {node: '>=12'} + dependencies: + '@jridgewell/trace-mapping': 0.3.9 + dev: true + + /@hapi/accept/5.0.2: + resolution: {integrity: sha512-CmzBx/bXUR8451fnZRuZAJRlzgm0Jgu5dltTX/bszmR2lheb9BpyN47Q1RbaGTsvFzn0PXAEs+lXDKfshccYZw==} + dependencies: + '@hapi/boom': 9.1.4 + '@hapi/hoek': 9.3.0 + dev: false + + /@hapi/ammo/5.0.1: + resolution: {integrity: sha512-FbCNwcTbnQP4VYYhLNGZmA76xb2aHg9AMPiy18NZyWMG310P5KdFGyA9v2rm5ujrIny77dEEIkMOwl0Xv+fSSA==} + dependencies: + '@hapi/hoek': 9.3.0 + dev: false + + /@hapi/ammo/6.0.0: + resolution: {integrity: sha512-lhX7SYtWScQaeAIL5XnE54WzyDgS5RXVeEtFEovyZcTdVzTYbo0nem56Bwko1PBcRxRUIw1v2tMb6sjFs6vEwg==} + dependencies: + '@hapi/hoek': 10.0.1 + dev: false + + /@hapi/b64/5.0.0: + resolution: {integrity: sha512-ngu0tSEmrezoiIaNGG6rRvKOUkUuDdf4XTPnONHGYfSGRmDqPZX5oJL6HAdKTo1UQHECbdB4OzhWrfgVppjHUw==} + dependencies: + '@hapi/hoek': 9.3.0 + + /@hapi/boom/10.0.0: + resolution: {integrity: sha512-1YVs9tLHhypBqqinKQRqh7FUERIolarQApO37OWkzD+z6y6USi871Sv746zBPKcIOBuI6g6y4FrwX87mmJ90Gg==} + dependencies: + '@hapi/hoek': 10.0.1 + dev: false + + /@hapi/boom/9.1.4: + resolution: {integrity: sha512-Ls1oH8jaN1vNsqcaHVYJrKmgMcKsC1wcp8bujvXrHaAqD2iDYq3HoOwsxwo09Cuda5R5nC0o0IxlrlTuvPuzSw==} + dependencies: + '@hapi/hoek': 9.3.0 + + /@hapi/bounce/2.0.0: + resolution: {integrity: sha512-JesW92uyzOOyuzJKjoLHM1ThiOvHPOLDHw01YV8yh5nCso7sDwJho1h0Ad2N+E62bZyz46TG3xhAi/78Gsct6A==} + dependencies: + '@hapi/boom': 9.1.4 + '@hapi/hoek': 9.3.0 + dev: false + + /@hapi/bounce/3.0.0: + resolution: {integrity: sha512-L0G4NcwwOYRhpcXeL76hNrLTUcObqtZMB3z4kcRVUZcR/w3v6C5Q1cTElV4/V7og1fG+wOyDR55UMFA+tWfhtA==} + dependencies: + '@hapi/boom': 10.0.0 + '@hapi/hoek': 10.0.1 + dev: false + + /@hapi/bourne/2.1.0: + resolution: {integrity: sha512-i1BpaNDVLJdRBEKeJWkVO6tYX6DMFBuwMhSuWqLsY4ufeTKGVuV5rBsUhxPayXqnnWHgXUAmWK16H/ykO5Wj4Q==} + + /@hapi/call/8.0.1: + resolution: {integrity: sha512-bOff6GTdOnoe5b8oXRV3lwkQSb/LAWylvDMae6RgEWWntd0SHtkYbQukDHKlfaYtVnSAgIavJ0kqszF/AIBb6g==} + dependencies: + '@hapi/boom': 9.1.4 + '@hapi/hoek': 9.3.0 + dev: false + + /@hapi/catbox-memory/5.0.1: + resolution: {integrity: sha512-QWw9nOYJq5PlvChLWV8i6hQHJYfvdqiXdvTupJFh0eqLZ64Xir7mKNi96d5/ZMUAqXPursfNDIDxjFgoEDUqeQ==} + dependencies: + '@hapi/boom': 9.1.4 + '@hapi/hoek': 9.3.0 + dev: false + + /@hapi/catbox/11.1.1: + resolution: {integrity: sha512-u/8HvB7dD/6X8hsZIpskSDo4yMKpHxFd7NluoylhGrL6cUfYxdQPnvUp9YU2C6F9hsyBVLGulBd9vBN1ebfXOQ==} + dependencies: + '@hapi/boom': 9.1.4 + '@hapi/hoek': 9.3.0 + '@hapi/podium': 4.1.3 + '@hapi/validate': 1.1.3 + dev: false + + /@hapi/content/5.0.2: + resolution: {integrity: sha512-mre4dl1ygd4ZyOH3tiYBrOUBzV7Pu/EOs8VLGf58vtOEECWed8Uuw6B4iR9AN/8uQt42tB04qpVaMyoMQh0oMw==} + dependencies: + '@hapi/boom': 9.1.4 + dev: false + + /@hapi/cryptiles/5.1.0: + resolution: {integrity: sha512-fo9+d1Ba5/FIoMySfMqPBR/7Pa29J2RsiPrl7bkwo5W5o+AN1dAYQRi4SPrPwwVxVGKjgLOEWrsvt1BonJSfLA==} + engines: {node: '>=12.0.0'} + dependencies: + '@hapi/boom': 9.1.4 + + /@hapi/file/2.0.0: + resolution: {integrity: sha512-WSrlgpvEqgPWkI18kkGELEZfXr0bYLtr16iIN4Krh9sRnzBZN6nnWxHFxtsnP684wueEySBbXPDg/WfA9xJdBQ==} + dev: false + + /@hapi/hapi/20.2.2: + resolution: {integrity: sha512-crhU6TIKt7QsksWLYctDBAXogk9PYAm7UzdpETyuBHC2pCa6/+B5NykiOVLG/3FCIgHo/raPVtan8bYtByHORQ==} + engines: {node: '>=12.0.0'} + dependencies: + '@hapi/accept': 5.0.2 + '@hapi/ammo': 5.0.1 + '@hapi/boom': 9.1.4 + '@hapi/bounce': 2.0.0 + '@hapi/call': 8.0.1 + '@hapi/catbox': 11.1.1 + '@hapi/catbox-memory': 5.0.1 + '@hapi/heavy': 7.0.1 + '@hapi/hoek': 9.3.0 + '@hapi/mimos': 6.0.0 + '@hapi/podium': 4.1.3 + '@hapi/shot': 5.0.5 + '@hapi/somever': 3.0.1 + '@hapi/statehood': 7.0.4 + '@hapi/subtext': 7.0.4 + '@hapi/teamwork': 5.1.1 + '@hapi/topo': 5.1.0 + '@hapi/validate': 1.1.3 + dev: false + + /@hapi/heavy/7.0.1: + resolution: {integrity: sha512-vJ/vzRQ13MtRzz6Qd4zRHWS3FaUc/5uivV2TIuExGTM9Qk+7Zzqj0e2G7EpE6KztO9SalTbiIkTh7qFKj/33cA==} + dependencies: + '@hapi/boom': 9.1.4 + '@hapi/hoek': 9.3.0 + '@hapi/validate': 1.1.3 + dev: false + + /@hapi/hoek/10.0.1: + resolution: {integrity: sha512-CvlW7jmOhWzuqOqiJQ3rQVLMcREh0eel4IBnxDx2FAcK8g7qoJRQK4L1CPBASoCY6y8e6zuCy3f2g+HWdkzcMw==} + dev: false + + /@hapi/hoek/9.3.0: + resolution: {integrity: sha512-/c6rf4UJlmHlC9b5BaNvzAcFv7HZ2QHaV0D4/HNlBdvFnvQq8RI4kYdhyPCl7Xj+oWvTWQ8ujhqS53LIgAe6KQ==} + + /@hapi/inert/7.0.0: + resolution: {integrity: sha512-aJvH8rKYF42YY/XZLtq5LOWyk71GRIlcqRgvRyz+XQnj2DTdSZeerUcsxV2kyzJVm9gdemVwHp00foLfKadbMg==} + dependencies: + '@hapi/ammo': 6.0.0 + '@hapi/boom': 10.0.0 + '@hapi/bounce': 3.0.0 + '@hapi/hoek': 10.0.1 + '@hapi/validate': 2.0.0 + lru-cache: 7.13.2 + dev: false + + /@hapi/iron/6.0.0: + resolution: {integrity: sha512-zvGvWDufiTGpTJPG1Y/McN8UqWBu0k/xs/7l++HVU535NLHXsHhy54cfEMdW7EjwKfbBfM9Xy25FmTiobb7Hvw==} + dependencies: + '@hapi/b64': 5.0.0 + '@hapi/boom': 9.1.4 + '@hapi/bourne': 2.1.0 + '@hapi/cryptiles': 5.1.0 + '@hapi/hoek': 9.3.0 + + /@hapi/mimos/6.0.0: + resolution: {integrity: sha512-Op/67tr1I+JafN3R3XN5DucVSxKRT/Tc+tUszDwENoNpolxeXkhrJ2Czt6B6AAqrespHoivhgZBWYSuANN9QXg==} + dependencies: + '@hapi/hoek': 9.3.0 + mime-db: 1.52.0 + dev: false + + /@hapi/nigel/4.0.2: + resolution: {integrity: sha512-ht2KoEsDW22BxQOEkLEJaqfpoKPXxi7tvabXy7B/77eFtOyG5ZEstfZwxHQcqAiZhp58Ae5vkhEqI03kawkYNw==} + engines: {node: '>=12.0.0'} + dependencies: + '@hapi/hoek': 9.3.0 + '@hapi/vise': 4.0.0 + dev: false + + /@hapi/pez/5.0.3: + resolution: {integrity: sha512-mpikYRJjtrbJgdDHG/H9ySqYqwJ+QU/D7FXsYciS9P7NYBXE2ayKDAy3H0ou6CohOCaxPuTV4SZ0D936+VomHA==} + dependencies: + '@hapi/b64': 5.0.0 + '@hapi/boom': 9.1.4 + '@hapi/content': 5.0.2 + '@hapi/hoek': 9.3.0 + '@hapi/nigel': 4.0.2 + dev: false + + /@hapi/podium/4.1.3: + resolution: {integrity: sha512-ljsKGQzLkFqnQxE7qeanvgGj4dejnciErYd30dbrYzUOF/FyS/DOF97qcrT3bhoVwCYmxa6PEMhxfCPlnUcD2g==} + dependencies: + '@hapi/hoek': 9.3.0 + '@hapi/teamwork': 5.1.1 + '@hapi/validate': 1.1.3 + + /@hapi/shot/5.0.5: + resolution: {integrity: sha512-x5AMSZ5+j+Paa8KdfCoKh+klB78otxF+vcJR/IoN91Vo2e5ulXIW6HUsFTCU+4W6P/Etaip9nmdAx2zWDimB2A==} + dependencies: + '@hapi/hoek': 9.3.0 + '@hapi/validate': 1.1.3 + dev: false + + /@hapi/somever/3.0.1: + resolution: {integrity: sha512-4ZTSN3YAHtgpY/M4GOtHUXgi6uZtG9nEZfNI6QrArhK0XN/RDVgijlb9kOmXwCR5VclDSkBul9FBvhSuKXx9+w==} + dependencies: + '@hapi/bounce': 2.0.0 + '@hapi/hoek': 9.3.0 + dev: false + + /@hapi/statehood/7.0.4: + resolution: {integrity: sha512-Fia6atroOVmc5+2bNOxF6Zv9vpbNAjEXNcUbWXavDqhnJDlchwUUwKS5LCi5mGtCTxRhUKKHwuxuBZJkmLZ7fw==} + dependencies: + '@hapi/boom': 9.1.4 + '@hapi/bounce': 2.0.0 + '@hapi/bourne': 2.1.0 + '@hapi/cryptiles': 5.1.0 + '@hapi/hoek': 9.3.0 + '@hapi/iron': 6.0.0 + '@hapi/validate': 1.1.3 + dev: false + + /@hapi/subtext/7.0.4: + resolution: {integrity: sha512-Y72moHhbRuO8kwBHFEnCRw7oOnhNh4Pl+aonxAze18jkyMpE4Gwz4lNID7ei8vd3lpXC2rKdkxXJgtfY+WttRw==} + dependencies: + '@hapi/boom': 9.1.4 + '@hapi/bourne': 2.1.0 + '@hapi/content': 5.0.2 + '@hapi/file': 2.0.0 + '@hapi/hoek': 9.3.0 + '@hapi/pez': 5.0.3 + '@hapi/wreck': 17.2.0 + dev: false + + /@hapi/teamwork/5.1.1: + resolution: {integrity: sha512-1oPx9AE5TIv+V6Ih54RP9lTZBso3rP8j4Xhb6iSVwPXtAM+sDopl5TFMv5Paw73UnpZJ9gjcrTE1BXrWt9eQrg==} + engines: {node: '>=12.0.0'} + + /@hapi/topo/5.1.0: + resolution: {integrity: sha512-foQZKJig7Ob0BMAYBfcJk8d77QtOe7Wo4ox7ff1lQYoNNAb6jwcY1ncdoy2e9wQZzvNy7ODZCYJkK8kzmcAnAg==} + dependencies: + '@hapi/hoek': 9.3.0 + + /@hapi/topo/6.0.0: + resolution: {integrity: sha512-aorJvN1Q1n5xrZuA50Z4X6adI6VAM2NalIVm46ALL9LUvdoqhof3JPY69jdJH8asM3PsWr2SUVYzp57EqUP41A==} + dependencies: + '@hapi/hoek': 10.0.1 + dev: false + + /@hapi/validate/1.1.3: + resolution: {integrity: sha512-/XMR0N0wjw0Twzq2pQOzPBZlDzkekGcoCtzO314BpIEsbXdYGthQUbxgkGDf4nhk1+IPDAsXqWjMohRQYO06UA==} + dependencies: + '@hapi/hoek': 9.3.0 + '@hapi/topo': 5.1.0 + + /@hapi/validate/2.0.0: + resolution: {integrity: sha512-w5m8MvBgqGndbMIB+AWmXTb8CLtF1DlIxbnbAHNAo7aFuNQuI1Ywc2e0zDLK5fbFXDoqRzNrHnC7JjNJ+hDigw==} + dependencies: + '@hapi/hoek': 10.0.1 + '@hapi/topo': 6.0.0 + dev: false + + /@hapi/vise/4.0.0: + resolution: {integrity: sha512-eYyLkuUiFZTer59h+SGy7hUm+qE9p+UemePTHLlIWppEd+wExn3Df5jO04bFQTm7nleF5V8CtuYQYb+VFpZ6Sg==} + dependencies: + '@hapi/hoek': 9.3.0 + dev: false + + /@hapi/wreck/17.2.0: + resolution: {integrity: sha512-pJ5kjYoRPYDv+eIuiLQqhGon341fr2bNIYZjuotuPJG/3Ilzr/XtI+JAp0A86E2bYfsS3zBPABuS2ICkaXFT8g==} + dependencies: + '@hapi/boom': 9.1.4 + '@hapi/bourne': 2.1.0 + '@hapi/hoek': 9.3.0 + dev: false + + /@iarna/toml/2.2.5: + resolution: {integrity: sha512-trnsAYxU3xnS1gPHPyU961coFyLkh4gAD/0zQ5mymY4yOZ+CYvsPqUbOFSw0aDM4y0tV7tiFxL/1XfXPNC6IPg==} + dev: false + + /@jridgewell/resolve-uri/3.1.0: + resolution: {integrity: sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==} + engines: {node: '>=6.0.0'} + dev: true + + /@jridgewell/sourcemap-codec/1.4.14: + resolution: {integrity: sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==} + dev: true + + /@jridgewell/trace-mapping/0.3.9: + resolution: {integrity: sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==} + dependencies: + '@jridgewell/resolve-uri': 3.1.0 + '@jridgewell/sourcemap-codec': 1.4.14 + dev: true + + /@sideway/address/4.1.4: + resolution: {integrity: sha512-7vwq+rOHVWjyXxVlR76Agnvhy8I9rpzjosTESvmhNeXOXdZZB15Fl+TI9x1SiHZH5Jv2wTGduSxFDIaq0m3DUw==} + dependencies: + '@hapi/hoek': 9.3.0 + + /@sideway/formula/3.0.0: + resolution: {integrity: sha512-vHe7wZ4NOXVfkoRb8T5otiENVlT7a3IAiw7H5M2+GO+9CDgcVUUsX1zalAztCmwyOr2RUTGJdgB+ZvSVqmdHmg==} + + /@sideway/pinpoint/2.0.0: + resolution: {integrity: sha512-RNiOoTPkptFtSVzQevY/yWtZwf/RxyVnPy/OcA9HBM3MlGDnBEYL5B41H0MTn0Uec8Hi+2qUtTfG2WWZBmMejQ==} + + /@tsconfig/node10/1.0.9: + resolution: {integrity: sha512-jNsYVVxU8v5g43Erja32laIDHXeoNvFEpX33OK4d6hljo3jDhCBDhx5dhCCTMWUojscpAagGiRkBKxpdl9fxqA==} + dev: true + + /@tsconfig/node12/1.0.11: + resolution: {integrity: sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==} + dev: true + + /@tsconfig/node14/1.0.3: + resolution: {integrity: sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==} + dev: true + + /@tsconfig/node16/1.0.3: + resolution: {integrity: sha512-yOlFc+7UtL/89t2ZhjPvvB/DeAr3r+Dq58IgzsFkOAvVC6NMJXmCGjbptdXdR9qsX7pKcTL+s87FtYREi2dEEQ==} + dev: true + + /@types/glob/7.2.0: + resolution: {integrity: sha512-ZUxbzKl0IfJILTS6t7ip5fQQM/J3TJYubDm3nMbgubNNYS62eXeUpoLUC8/7fJNiFYHTrGPQn7hspDUzIHX3UA==} + dependencies: + '@types/minimatch': 3.0.5 + '@types/node': 18.6.4 + dev: true + + /@types/hapi__catbox/10.2.4: + resolution: {integrity: sha512-A6ivRrXD5glmnJna1UAGw87QNZRp/vdFO9U4GS+WhOMWzHnw+oTGkMvg0g6y1930CbeheGOCm7A1qHsqH7AXqg==} + dev: true + + /@types/hapi__hapi/20.0.12: + resolution: {integrity: sha512-B+0fceCzFvbIOVv5YWOZzbHtEff8BLlGH3etrkcOedyj7F0unC5FjzFfaaO5gwlhJDdX0cmmMeRg2pwRdMa2CQ==} + dependencies: + '@hapi/boom': 9.1.4 + '@hapi/iron': 6.0.0 + '@hapi/podium': 4.1.3 + '@types/hapi__catbox': 10.2.4 + '@types/hapi__mimos': 4.1.4 + '@types/hapi__shot': 4.1.2 + '@types/node': 18.6.4 + joi: 17.6.0 + dev: true + + /@types/hapi__inert/5.2.3: + resolution: {integrity: sha512-I1mWQrEc7oMqGtofT0rwBgRBCBurz0wNzbq8QZsHWR+aXM0bk1j9GA6zwyGIeO53PNl2C1c2kpXlc084xCV+Tg==} + dependencies: + '@types/hapi__hapi': 20.0.12 + dev: true + + /@types/hapi__mimos/4.1.4: + resolution: {integrity: sha512-i9hvJpFYTT/qzB5xKWvDYaSXrIiNqi4ephi+5Lo6+DoQdwqPXQgmVVOZR+s3MBiHoFqsCZCX9TmVWG3HczmTEQ==} + dependencies: + '@types/mime-db': 1.43.1 + dev: true + + /@types/hapi__shot/4.1.2: + resolution: {integrity: sha512-8wWgLVP1TeGqgzZtCdt+F+k15DWQvLG1Yv6ZzPfb3D5WIo5/S+GGKtJBVo2uNEcqabP5Ifc71QnJTDnTmw1axA==} + dependencies: + '@types/node': 18.6.4 + dev: true + + /@types/mime-db/1.43.1: + resolution: {integrity: sha512-kGZJY+R+WnR5Rk+RPHUMERtb2qBRViIHCBdtUrY+NmwuGb8pQdfTqQiCKPrxpdoycl8KWm2DLdkpoSdt479XoQ==} + dev: true + + /@types/minimatch/3.0.5: + resolution: {integrity: sha512-Klz949h02Gz2uZCMGwDUSDS1YBlTdDDgbWHi+81l29tQALUtvz4rAYi5uoVhE5Lagoq6DeqAUlbrHvW/mXDgdQ==} + dev: true + + /@types/module-alias/2.0.1: + resolution: {integrity: sha512-DN/CCT1HQG6HquBNJdLkvV+4v5l/oEuwOHUPLxI+Eub0NED+lk0YUfba04WGH90EINiUrNgClkNnwGmbICeWMQ==} + dev: true + + /@types/node/18.6.4: + resolution: {integrity: sha512-I4BD3L+6AWiUobfxZ49DlU43gtI+FTHSv9pE2Zekg6KjMpre4ByusaljW3vYSLJrvQ1ck1hUaeVu8HVlY3vzHg==} + dev: true + + /acorn-walk/8.2.0: + resolution: {integrity: sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==} + engines: {node: '>=0.4.0'} + dev: true + + /acorn/8.8.0: + resolution: {integrity: sha512-QOxyigPVrpZ2GXT+PFyZTl6TtOFc5egxHIP9IlQ+RbupQuX4RkT/Bee4/kQuC02Xkzg84JcT7oLYtDIQxp+v7w==} + engines: {node: '>=0.4.0'} + hasBin: true + dev: true + + /arg/4.1.3: + resolution: {integrity: sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==} + dev: true + + /balanced-match/1.0.2: + resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==} + dev: false + + /brace-expansion/2.0.1: + resolution: {integrity: sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==} + dependencies: + balanced-match: 1.0.2 + dev: false + + /buffer-from/1.1.2: + resolution: {integrity: sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==} + dev: false + + /create-require/1.1.1: + resolution: {integrity: sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==} + dev: true + + /diff/4.0.2: + resolution: {integrity: sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==} + engines: {node: '>=0.3.1'} + dev: true + + /fs.realpath/1.0.0: + resolution: {integrity: sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==} + dev: false + + /glob/8.0.3: + resolution: {integrity: sha512-ull455NHSHI/Y1FqGaaYFaLGkNMMJbavMrEGFXG/PGrg6y7sutWHUHrz6gy6WEBH6akM1M414dWKCNs+IhKdiQ==} + engines: {node: '>=12'} + dependencies: + fs.realpath: 1.0.0 + inflight: 1.0.6 + inherits: 2.0.4 + minimatch: 5.1.0 + once: 1.4.0 + dev: false + + /inflight/1.0.6: + resolution: {integrity: sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==} + dependencies: + once: 1.4.0 + wrappy: 1.0.2 + dev: false + + /inherits/2.0.3: + resolution: {integrity: sha512-x00IRNXNy63jwGkJmzPigoySHbaqpNuzKbBOmzK+g2OdZpQ9w+sxCN+VSB3ja7IAge2OP2qpfxTjeNcyjmW1uw==} + dev: false + + /inherits/2.0.4: + resolution: {integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==} + dev: false + + /joi-to-typescript/4.0.5_joi@17.6.0: + resolution: {integrity: sha512-VzI4ILDblFJFx9HfGXHZOdT6K729mKzhcvGSNTd2uJxfBOWKWonh5YdabttWdvHmiDzPfdJwzB2/zH8xRgV3EQ==} + engines: {node: '>=12.0.0'} + peerDependencies: + joi: 17.x + dependencies: + joi: 17.6.0 + dev: true + + /joi/17.6.0: + resolution: {integrity: sha512-OX5dG6DTbcr/kbMFj0KGYxuew69HPcAE3K/sZpEV2nP6e/j/C0HV+HNiBPCASxdx5T7DMoa0s8UeHWMnb6n2zw==} + dependencies: + '@hapi/hoek': 9.3.0 + '@hapi/topo': 5.1.0 + '@sideway/address': 4.1.4 + '@sideway/formula': 3.0.0 + '@sideway/pinpoint': 2.0.0 + + /lru-cache/7.13.2: + resolution: {integrity: sha512-VJL3nIpA79TodY/ctmZEfhASgqekbT574/c4j3jn4bKXbSCnTTCH/KltZyvL2GlV+tGSMtsWyem8DCX7qKTMBA==} + engines: {node: '>=12'} + dev: false + + /make-error/1.3.6: + resolution: {integrity: sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==} + dev: true + + /mime-db/1.52.0: + resolution: {integrity: sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==} + engines: {node: '>= 0.6'} + dev: false + + /minimatch/5.1.0: + resolution: {integrity: sha512-9TPBGGak4nHfGZsPBohm9AWg6NoT7QTCehS3BIJABslyZbzxfV78QM2Y6+i741OPZIafFAaiiEMh5OyIrJPgtg==} + engines: {node: '>=10'} + dependencies: + brace-expansion: 2.0.1 + dev: false + + /module-alias/2.2.2: + resolution: {integrity: sha512-A/78XjoX2EmNvppVWEhM2oGk3x4lLxnkEA4jTbaK97QKSDjkIoOsKQlfylt/d3kKKi596Qy3NP5XrXJ6fZIC9Q==} + dev: false + + /once/1.4.0: + resolution: {integrity: sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==} + dependencies: + wrappy: 1.0.2 + dev: false + + /path/0.12.7: + resolution: {integrity: sha512-aXXC6s+1w7otVF9UletFkFcDsJeO7lSZBPUQhtb5O0xJe8LtYhj/GxldoL09bBj9+ZmE2hNoHqQSFMN5fikh4Q==} + dependencies: + process: 0.11.10 + util: 0.10.4 + dev: false + + /process/0.11.10: + resolution: {integrity: sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==} + engines: {node: '>= 0.6.0'} + dev: false + + /source-map-support/0.5.21: + resolution: {integrity: sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==} + dependencies: + buffer-from: 1.1.2 + source-map: 0.6.1 + dev: false + + /source-map/0.6.1: + resolution: {integrity: sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==} + engines: {node: '>=0.10.0'} + dev: false + + /ts-node/10.9.1_hn66opzbaneygq52jmwjxha6su: + resolution: {integrity: sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==} + hasBin: true + peerDependencies: + '@swc/core': '>=1.2.50' + '@swc/wasm': '>=1.2.50' + '@types/node': '*' + typescript: '>=2.7' + peerDependenciesMeta: + '@swc/core': + optional: true + '@swc/wasm': + optional: true + dependencies: + '@cspotcode/source-map-support': 0.8.1 + '@tsconfig/node10': 1.0.9 + '@tsconfig/node12': 1.0.11 + '@tsconfig/node14': 1.0.3 + '@tsconfig/node16': 1.0.3 + '@types/node': 18.6.4 + acorn: 8.8.0 + acorn-walk: 8.2.0 + arg: 4.1.3 + create-require: 1.1.1 + diff: 4.0.2 + make-error: 1.3.6 + typescript: 4.7.4 + v8-compile-cache-lib: 3.0.1 + yn: 3.1.1 + dev: true + + /tslog/3.3.4: + resolution: {integrity: sha512-N0HHuHE0e/o75ALfkioFObknHR5dVchUad4F0XyFf3gXJYB++DewEzwGI/uIOM216E5a43ovnRNEeQIq9qgm4Q==} + engines: {node: '>=10'} + dependencies: + source-map-support: 0.5.21 + dev: false + + /typescript/4.7.4: + resolution: {integrity: sha512-C0WQT0gezHuw6AdY1M2jxUO83Rjf0HP7Sk1DtXj6j1EwkQNZrHAg2XPWlq62oqEhYvONq5pkC2Y9oPljWToLmQ==} + engines: {node: '>=4.2.0'} + hasBin: true + + /util/0.10.4: + resolution: {integrity: sha512-0Pm9hTQ3se5ll1XihRic3FDIku70C+iHUdT/W926rSgHV5QgXsYbKZN8MSC3tJtSkhuROzvsQjAaFENRXr+19A==} + dependencies: + inherits: 2.0.3 + dev: false + + /v8-compile-cache-lib/3.0.1: + resolution: {integrity: sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==} + dev: true + + /wrappy/1.0.2: + resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==} + dev: false + + /yn/3.1.1: + resolution: {integrity: sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==} + engines: {node: '>=6'} + dev: true diff --git a/src/endpoints/ping.ts b/src/endpoints/ping.ts new file mode 100644 index 0000000..f822811 --- /dev/null +++ b/src/endpoints/ping.ts @@ -0,0 +1,10 @@ +import { ServerRoute } from "@hapi/hapi"; + +const route: ServerRoute = { + method: `*`, path: `/ping`, + options: {}, + async handler() { + return `pong!`; + }, +}; +export default route; \ No newline at end of file diff --git a/src/main.ts b/src/main.ts new file mode 100644 index 0000000..29f284b --- /dev/null +++ b/src/main.ts @@ -0,0 +1,60 @@ +// Filepath aliasing to avoid relative-imports whenever possible, this must stay +// at the top of this file as the first statement +import "module-alias/register"; + +import { JSONDatabase } from "./utils/database/json"; +import { Server, Request } from "@hapi/hapi"; +import { loadConfig } from "./utils/config"; +import inert from "@hapi/inert"; +import { Logger } from "tslog"; +import path from "path"; +import glob from "glob"; + + +export const isDev = process.env.NODE_ENV?.startsWith(`dev`); +export const config = loadConfig(); +export const database = new JSONDatabase(config.database); +export const log = new Logger({ + displayFilePath: `hidden`, + displayFunctionName: false, + minLevel: isDev ? `silly` : `info` +}); + +// Handle the system exiting so we can cleanup before shutting down +import { cleanExit } from "./utils/cleanExit"; +process.on(`uncaughtException`, cleanExit); +process.on(`SIGTERM`, cleanExit); +process.on(`SIGINT`, cleanExit); + + +async function init() { + + const server = new Server({ + port: config.server.port, + routes: { + files: { + relativeTo: path.join(__dirname, `../site`), + }, + cors: true, + }, + }); + + await server.register(inert); + + // Register all the routes + let files = glob.sync( + `endpoints/**/!(*.map)`, + { cwd: __dirname, nodir: true} + ); + for (var file of files) { + let route = (await import(path.join(__dirname, file))).default; + console.log(`Registering route: ${route.method} ${route.path}`); + server.route(route); + }; + + server.start().then(() => { + console.log(`Server listening on ${server.info.uri}`); + }); +}; + +init(); \ No newline at end of file diff --git a/src/schemas/config.ts b/src/schemas/config.ts new file mode 100644 index 0000000..15bb2a2 --- /dev/null +++ b/src/schemas/config.ts @@ -0,0 +1,30 @@ +import Joi from "joi"; + + +export const serverOptionsSchema = Joi.object({ + port: Joi + .number() + .port() + .required() + .description(`The port the server will run on`), +}) +.meta({ className: `serverOptions` }) +.description(`The web server options`); + + +export const databaseOptionsSchema = Joi.object({ + uri: Joi + .string() + .required() + .description(`The location indicator where the database is. This can be a filepath or a socket URI, depending on what database is being used.`), +}) +.meta({ className: `databaseOptions` }) +.description(`The database specific options`); + + +export const configSchema = Joi.object({ + server: serverOptionsSchema.required(), + database: databaseOptionsSchema.required(), +}) +.meta({ className: `config` }) +.description(`The configuration format for the server`); \ No newline at end of file diff --git a/src/utils/cleanExit.ts b/src/utils/cleanExit.ts new file mode 100644 index 0000000..2c96e20 --- /dev/null +++ b/src/utils/cleanExit.ts @@ -0,0 +1,3 @@ +export function cleanExit() { + process.exit(0); +}; \ No newline at end of file diff --git a/src/utils/config.ts b/src/utils/config.ts new file mode 100644 index 0000000..a022724 --- /dev/null +++ b/src/utils/config.ts @@ -0,0 +1,48 @@ +import { configSchema } from "$/schemas/config"; +import type { config } from "$/types/config"; +import { isDev } from "$/main"; +import toml from "@iarna/toml"; +import fs from "fs"; + + +/** + * Attempts to load the config from disk and validate it's structure. + */ +export function loadConfig() { + let file = null; + + if (isDev) { + try { + file = fs.readFileSync(`./config.dev.toml`, `utf-8`); + } catch (_) { + console.error(`Couldn't find development config, checking production`); + }; + }; + + if (!file) { + try { + file = fs.readFileSync(`./config.toml`, `utf-8`); + } catch (_) { + console.error(`Couldn't find production config. Fill out the config and run the server again`); + process.exit(1); + }; + }; + + try { + var data = toml.parse(file); + } catch (_) { + console.error(`Invalid TOML file, stopping server`); + process.exit(1); + }; + + let { error, value } = configSchema.validate(data, { abortEarly: false }); + if (error) { + console.error(`Config failed to validate, see below for details:`) + for (const err of error.details) { + console.error(` - ${err.message}`); + }; + process.exit(1); + }; + + return value as config; +}; \ No newline at end of file diff --git a/src/utils/database/json.ts b/src/utils/database/json.ts new file mode 100644 index 0000000..03a23b8 --- /dev/null +++ b/src/utils/database/json.ts @@ -0,0 +1,25 @@ +import { databaseOptions } from "$/types/config"; +import fs from "fs"; + +export class JSONDatabase { + private data = {}; + private conf: databaseOptions; + + constructor(conf: databaseOptions) { + this.conf = conf; + + if (!fs.existsSync(conf.uri)) { + console.error(`Can't find database file, creating default`); + try { + fs.writeFileSync(conf.uri, `{}`); + } catch (_) { + console.log(`Couldn't create database file, ensure the uri is a valid filepath`); + }; + }; + this.data = JSON.parse(fs.readFileSync(conf.uri, `utf-8`)); + }; + + public shutdown() { + fs.writeFileSync(this.conf.uri, JSON.stringify(this.data)); + }; +}; \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..edb5e35 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,108 @@ +{ + "compilerOptions": { + /* Visit https://aka.ms/tsconfig to read more about this file */ + + /* Projects */ + "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */ + // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ + // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */ + // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */ + // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ + // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ + + /* Language and Environment */ + "target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ + // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ + // "jsx": "preserve", /* Specify what JSX code is generated. */ + // "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */ + // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ + // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */ + // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ + // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */ + // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */ + // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ + // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ + // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ + + /* Modules */ + "module": "commonjs", /* Specify what module code is generated. */ + "rootDir": "./src", /* Specify the root folder within your source files. */ + // "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */ + // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ + "paths": { + "$/*": [ "./src/*" ] + }, /* Specify a set of entries that re-map imports to additional lookup locations. */ + // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ + // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */ + // "types": [], /* Specify type package names to be included without being referenced in a source file. */ + // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ + // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ + // "resolveJsonModule": true, /* Enable importing .json files. */ + // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ + + /* JavaScript Support */ + // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */ + // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ + // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ + + /* Emit */ + // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ + // "declarationMap": true, /* Create sourcemaps for d.ts files. */ + // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ + // "sourceMap": true, /* Create source map files for emitted JavaScript files. */ + // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ + // "outDir": "./", /* Specify an output folder for all emitted files. */ + // "removeComments": true, /* Disable emitting comments. */ + // "noEmit": true, /* Disable emitting files from a compilation. */ + // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ + // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */ + // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ + // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ + // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ + "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ + // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ + // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ + // "newLine": "crlf", /* Set the newline character for emitting files. */ + "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */ + // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */ + // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ + // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */ + // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ + // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */ + + /* Interop Constraints */ + // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ + // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ + "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */ + // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ + "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ + + /* Type Checking */ + "strict": true, /* Enable all strict type-checking options. */ + // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */ + // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */ + // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ + // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ + // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ + // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */ + // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */ + // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ + // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */ + // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */ + // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ + // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ + // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ + // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */ + // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ + // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */ + // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ + // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ + + /* Completeness */ + // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ + "skipLibCheck": true /* Skip type checking all .d.ts files. */ + }, + "exclude": [ + "./generateInterfaces.ts" + ] +}