From 8bc3f7fe3674b0877ec1df379625b37319ede1f0 Mon Sep 17 00:00:00 2001 From: Wolvan Date: Tue, 28 Dec 2021 21:11:19 +0100 Subject: [PATCH] Initial commit This code serves as an application framework of sorts and is totally not stolen from some of my other projects. --- .editorconfig | 7 + .eslintignore | 3 + .eslintrc.json | 44 + .gitignore | 113 + .mocharc.json | 8 + LICENSE | 21 + README.md | 32 + package-lock.json | 4114 +++++++++++++++++++++++++++++++++ package.json | 57 + src/config-handlers.ts | 24 + src/config-handlers/env.ts | 8 + src/config-handlers/file.ts | 14 + src/config-handlers/secret.ts | 14 + src/config-loader.ts | 70 + src/main.ts | 13 + test/const.ts | 9 + test/dummy.spec.ts | 4 + test/setup.ts | 17 + tsconfig.json | 73 + utils/todo-finder.js | 46 + 20 files changed, 4691 insertions(+) create mode 100644 .editorconfig create mode 100644 .eslintignore create mode 100644 .eslintrc.json create mode 100644 .gitignore create mode 100644 .mocharc.json create mode 100644 LICENSE create mode 100644 README.md create mode 100644 package-lock.json create mode 100644 package.json create mode 100644 src/config-handlers.ts create mode 100644 src/config-handlers/env.ts create mode 100644 src/config-handlers/file.ts create mode 100644 src/config-handlers/secret.ts create mode 100644 src/config-loader.ts create mode 100644 src/main.ts create mode 100644 test/const.ts create mode 100644 test/dummy.spec.ts create mode 100644 test/setup.ts create mode 100644 tsconfig.json create mode 100644 utils/todo-finder.js diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..0e720b4 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,7 @@ +root = true + +[*] +indent_style = space +indent_size = 4 +trim_trailing_whitespace = true +insert_final_newline = true diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..19d5bcc --- /dev/null +++ b/.eslintignore @@ -0,0 +1,3 @@ +dist/ +node_modules/ +utils/todo-finder.js diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000..a9f717f --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,44 @@ +{ + "env": { + "browser": false, + "commonjs": false, + "es6": true, + "node": true + }, + "root": true, + "parser": "@typescript-eslint/parser", + "plugins": [ + "@typescript-eslint", + "mocha", + "chai-expect" + ], + "extends": [ + "eslint:recommended", + "plugin:@typescript-eslint/eslint-recommended", + "plugin:@typescript-eslint/recommended", + "plugin:mocha/recommended", + "plugin:chai-expect/recommended" + ], + "parserOptions": { + "ecmaFeatures": { + "impliedStrict": true + }, + "sourceType": "module" + }, + "rules": { + "no-const-assign": "warn", + "no-this-before-super": "warn", + "no-undef": "warn", + "no-unreachable": "warn", + "semi-spacing": "warn", + "constructor-super": "warn", + "valid-typeof": "warn", + "default-case": "warn", + "array-bracket-spacing": "warn", + "brace-style": "warn", + "camelcase": "warn", + "no-fallthrough": "warn", + "@typescript-eslint/semi": "warn", + "@typescript-eslint/no-explicit-any": "off" + } +} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..00be38d --- /dev/null +++ b/.gitignore @@ -0,0 +1,113 @@ +# 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 + +# Testing directory +testing/ + +# SQLite database file +*.sqlite +*.sqlite3 +*.db +*.db3 \ No newline at end of file diff --git a/.mocharc.json b/.mocharc.json new file mode 100644 index 0000000..a19d4a7 --- /dev/null +++ b/.mocharc.json @@ -0,0 +1,8 @@ +{ + "extension": ["ts"], + "spec": "test/**/*.spec.ts", + "require": [ + "ts-node/register", + "test/setup.ts" + ] + } diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..3cd970b --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 NodeJSBots + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..e0eec84 --- /dev/null +++ b/README.md @@ -0,0 +1,32 @@ +# Poll.horse +### Simple polling service for public polls +With strawpoll being somewhat very broken I decided to implement my own. Let's go! + +## What is this +If you have never used strawpoll, in short this is a website to easily make small polls without a fuss. + + +## Contributing +The core is written in TypeScript, a typed superset to Javascript and executed with NodeJS. Pull Requests welcome. + +Before cloning this repository, make sure you have [Node](https://www.nodejs.org/) installed. + +Then clone this repository, open a terminal/command prompt and type `npm i` to install the required dependencies. + +`ts-node` is recommended to test during development, install it with `npm i -g ts-node typescript`. + +## Directory Structure +- `./dist` - The finalized and compiled files that can be used with node +- `./src` - The source files of the project +- `./test` - Files required for unit testing, aka test setup/teardown and test spec files +- `./utils` - Various utility scripts not part of the main source code + +## Scripts +Execute the scripts with `npm run