Removed old backend fully
This commit is contained in:
		@@ -1,29 +0,0 @@
 | 
				
			|||||||
module.exports = {
 | 
					 | 
				
			||||||
	parser: '@typescript-eslint/parser',
 | 
					 | 
				
			||||||
	parserOptions: {
 | 
					 | 
				
			||||||
		project: 'tsconfig.json',
 | 
					 | 
				
			||||||
		tsconfigRootDir: __dirname,
 | 
					 | 
				
			||||||
		sourceType: 'module',
 | 
					 | 
				
			||||||
	},
 | 
					 | 
				
			||||||
	plugins: ['@typescript-eslint/eslint-plugin', 'no-relative-import-paths'],
 | 
					 | 
				
			||||||
	extends: [
 | 
					 | 
				
			||||||
		'plugin:@typescript-eslint/recommended',
 | 
					 | 
				
			||||||
		'plugin:prettier/recommended',
 | 
					 | 
				
			||||||
	],
 | 
					 | 
				
			||||||
	root: true,
 | 
					 | 
				
			||||||
	env: {
 | 
					 | 
				
			||||||
		node: true,
 | 
					 | 
				
			||||||
		jest: true,
 | 
					 | 
				
			||||||
	},
 | 
					 | 
				
			||||||
	ignorePatterns: ['.eslintrc.js'],
 | 
					 | 
				
			||||||
	rules: {
 | 
					 | 
				
			||||||
		'@typescript-eslint/interface-name-prefix': 'off',
 | 
					 | 
				
			||||||
		'@typescript-eslint/explicit-function-return-type': 'off',
 | 
					 | 
				
			||||||
		'@typescript-eslint/explicit-module-boundary-types': 'off',
 | 
					 | 
				
			||||||
		'@typescript-eslint/no-explicit-any': 'off',
 | 
					 | 
				
			||||||
		'no-relative-import-paths/no-relative-import-paths': [
 | 
					 | 
				
			||||||
			'error',
 | 
					 | 
				
			||||||
			{ 'allowSameFolder': true, 'rootDir': 'src' }
 | 
					 | 
				
			||||||
		]
 | 
					 | 
				
			||||||
	},
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
							
								
								
									
										401
									
								
								old_backend/.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										401
									
								
								old_backend/.gitignore
									
									
									
									
										vendored
									
									
								
							@@ -1,401 +0,0 @@
 | 
				
			|||||||
# Created by .ignore support plugin (hsz.mobi)
 | 
					 | 
				
			||||||
### JetBrains template
 | 
					 | 
				
			||||||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
 | 
					 | 
				
			||||||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# User-specific stuff:
 | 
					 | 
				
			||||||
.idea/**/workspace.xml
 | 
					 | 
				
			||||||
.idea/**/tasks.xml
 | 
					 | 
				
			||||||
.idea/dictionaries
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Sensitive or high-churn files:
 | 
					 | 
				
			||||||
.idea/**/dataSources/
 | 
					 | 
				
			||||||
.idea/**/dataSources.ids
 | 
					 | 
				
			||||||
.idea/**/dataSources.xml
 | 
					 | 
				
			||||||
.idea/**/dataSources.local.xml
 | 
					 | 
				
			||||||
.idea/**/sqlDataSources.xml
 | 
					 | 
				
			||||||
.idea/**/dynamic.xml
 | 
					 | 
				
			||||||
.idea/**/uiDesigner.xml
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Gradle:
 | 
					 | 
				
			||||||
.idea/**/gradle.xml
 | 
					 | 
				
			||||||
.idea/**/libraries
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# CMake
 | 
					 | 
				
			||||||
cmake-build-debug/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Mongo Explorer plugin:
 | 
					 | 
				
			||||||
.idea/**/mongoSettings.xml
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
## File-based project format:
 | 
					 | 
				
			||||||
*.iws
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
## Plugin-specific files:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# IntelliJ
 | 
					 | 
				
			||||||
out/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# mpeltonen/sbt-idea plugin
 | 
					 | 
				
			||||||
.idea_modules/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# JIRA plugin
 | 
					 | 
				
			||||||
atlassian-ide-plugin.xml
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Cursive Clojure plugin
 | 
					 | 
				
			||||||
.idea/replstate.xml
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Crashlytics plugin (for Android Studio and IntelliJ)
 | 
					 | 
				
			||||||
com_crashlytics_export_strings.xml
 | 
					 | 
				
			||||||
crashlytics.properties
 | 
					 | 
				
			||||||
crashlytics-build.properties
 | 
					 | 
				
			||||||
fabric.properties
 | 
					 | 
				
			||||||
### VisualStudio template
 | 
					 | 
				
			||||||
## Ignore Visual Studio temporary files, build results, and
 | 
					 | 
				
			||||||
## files generated by popular Visual Studio add-ons.
 | 
					 | 
				
			||||||
##
 | 
					 | 
				
			||||||
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# User-specific files
 | 
					 | 
				
			||||||
*.suo
 | 
					 | 
				
			||||||
*.user
 | 
					 | 
				
			||||||
*.userosscache
 | 
					 | 
				
			||||||
*.sln.docstates
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# User-specific files (MonoDevelop/Xamarin Studio)
 | 
					 | 
				
			||||||
*.userprefs
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Build results
 | 
					 | 
				
			||||||
[Dd]ebug/
 | 
					 | 
				
			||||||
[Dd]ebugPublic/
 | 
					 | 
				
			||||||
[Rr]elease/
 | 
					 | 
				
			||||||
[Rr]eleases/
 | 
					 | 
				
			||||||
x64/
 | 
					 | 
				
			||||||
x86/
 | 
					 | 
				
			||||||
bld/
 | 
					 | 
				
			||||||
[Bb]in/
 | 
					 | 
				
			||||||
[Oo]bj/
 | 
					 | 
				
			||||||
[Ll]og/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Visual Studio 2015 cache/options directory
 | 
					 | 
				
			||||||
.vs/
 | 
					 | 
				
			||||||
# Uncomment if you have tasks that create the project's static files in wwwroot
 | 
					 | 
				
			||||||
#wwwroot/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# MSTest test Results
 | 
					 | 
				
			||||||
[Tt]est[Rr]esult*/
 | 
					 | 
				
			||||||
[Bb]uild[Ll]og.*
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# NUNIT
 | 
					 | 
				
			||||||
*.VisualState.xml
 | 
					 | 
				
			||||||
TestResult.xml
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Build Results of an ATL Project
 | 
					 | 
				
			||||||
[Dd]ebugPS/
 | 
					 | 
				
			||||||
[Rr]eleasePS/
 | 
					 | 
				
			||||||
dlldata.c
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Benchmark Results
 | 
					 | 
				
			||||||
BenchmarkDotNet.Artifacts/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# .NET Core
 | 
					 | 
				
			||||||
project.lock.json
 | 
					 | 
				
			||||||
project.fragment.lock.json
 | 
					 | 
				
			||||||
artifacts/
 | 
					 | 
				
			||||||
**/Properties/launchSettings.json
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
*_i.c
 | 
					 | 
				
			||||||
*_p.c
 | 
					 | 
				
			||||||
*_i.h
 | 
					 | 
				
			||||||
*.ilk
 | 
					 | 
				
			||||||
*.meta
 | 
					 | 
				
			||||||
*.obj
 | 
					 | 
				
			||||||
*.pch
 | 
					 | 
				
			||||||
*.pdb
 | 
					 | 
				
			||||||
*.pgc
 | 
					 | 
				
			||||||
*.pgd
 | 
					 | 
				
			||||||
*.rsp
 | 
					 | 
				
			||||||
*.sbr
 | 
					 | 
				
			||||||
*.tlb
 | 
					 | 
				
			||||||
*.tli
 | 
					 | 
				
			||||||
*.tlh
 | 
					 | 
				
			||||||
*.tmp
 | 
					 | 
				
			||||||
*.tmp_proj
 | 
					 | 
				
			||||||
*.log
 | 
					 | 
				
			||||||
*.vspscc
 | 
					 | 
				
			||||||
*.vssscc
 | 
					 | 
				
			||||||
.builds
 | 
					 | 
				
			||||||
*.pidb
 | 
					 | 
				
			||||||
*.svclog
 | 
					 | 
				
			||||||
*.scc
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Chutzpah Test files
 | 
					 | 
				
			||||||
_Chutzpah*
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Visual C++ cache files
 | 
					 | 
				
			||||||
ipch/
 | 
					 | 
				
			||||||
*.aps
 | 
					 | 
				
			||||||
*.ncb
 | 
					 | 
				
			||||||
*.opendb
 | 
					 | 
				
			||||||
*.opensdf
 | 
					 | 
				
			||||||
*.sdf
 | 
					 | 
				
			||||||
*.cachefile
 | 
					 | 
				
			||||||
*.VC.db
 | 
					 | 
				
			||||||
*.VC.VC.opendb
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Visual Studio profiler
 | 
					 | 
				
			||||||
*.psess
 | 
					 | 
				
			||||||
*.vsp
 | 
					 | 
				
			||||||
*.vspx
 | 
					 | 
				
			||||||
*.sap
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Visual Studio Trace Files
 | 
					 | 
				
			||||||
*.e2e
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# TFS 2012 Local Workspace
 | 
					 | 
				
			||||||
$tf/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Guidance Automation Toolkit
 | 
					 | 
				
			||||||
*.gpState
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# ReSharper is a .NET coding add-in
 | 
					 | 
				
			||||||
_ReSharper*/
 | 
					 | 
				
			||||||
*.[Rr]e[Ss]harper
 | 
					 | 
				
			||||||
*.DotSettings.user
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# JustCode is a .NET coding add-in
 | 
					 | 
				
			||||||
.JustCode
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# TeamCity is a build add-in
 | 
					 | 
				
			||||||
_TeamCity*
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# DotCover is a Code Coverage Tool
 | 
					 | 
				
			||||||
*.dotCover
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# AxoCover is a Code Coverage Tool
 | 
					 | 
				
			||||||
.axoCover/*
 | 
					 | 
				
			||||||
!.axoCover/settings.json
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Visual Studio code coverage results
 | 
					 | 
				
			||||||
*.coverage
 | 
					 | 
				
			||||||
*.coveragexml
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# NCrunch
 | 
					 | 
				
			||||||
_NCrunch_*
 | 
					 | 
				
			||||||
.*crunch*.local.xml
 | 
					 | 
				
			||||||
nCrunchTemp_*
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# MightyMoose
 | 
					 | 
				
			||||||
*.mm.*
 | 
					 | 
				
			||||||
AutoTest.Net/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Web workbench (sass)
 | 
					 | 
				
			||||||
.sass-cache/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Installshield output folder
 | 
					 | 
				
			||||||
[Ee]xpress/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# DocProject is a documentation generator add-in
 | 
					 | 
				
			||||||
DocProject/buildhelp/
 | 
					 | 
				
			||||||
DocProject/Help/*.HxT
 | 
					 | 
				
			||||||
DocProject/Help/*.HxC
 | 
					 | 
				
			||||||
DocProject/Help/*.hhc
 | 
					 | 
				
			||||||
DocProject/Help/*.hhk
 | 
					 | 
				
			||||||
DocProject/Help/*.hhp
 | 
					 | 
				
			||||||
DocProject/Help/Html2
 | 
					 | 
				
			||||||
DocProject/Help/html
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Click-Once directory
 | 
					 | 
				
			||||||
publish/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Publish Web Output
 | 
					 | 
				
			||||||
*.[Pp]ublish.xml
 | 
					 | 
				
			||||||
*.azurePubxml
 | 
					 | 
				
			||||||
# Note: Comment the next line if you want to checkin your web deploy settings,
 | 
					 | 
				
			||||||
# but database connection strings (with potential passwords) will be unencrypted
 | 
					 | 
				
			||||||
*.pubxml
 | 
					 | 
				
			||||||
*.publishproj
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Microsoft Azure Web App publish settings. Comment the next line if you want to
 | 
					 | 
				
			||||||
# checkin your Azure Web App publish settings, but sensitive information contained
 | 
					 | 
				
			||||||
# in these scripts will be unencrypted
 | 
					 | 
				
			||||||
PublishScripts/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# NuGet Packages
 | 
					 | 
				
			||||||
*.nupkg
 | 
					 | 
				
			||||||
# The packages folder can be ignored because of Package Restore
 | 
					 | 
				
			||||||
**/[Pp]ackages/*
 | 
					 | 
				
			||||||
# except build/, which is used as an MSBuild target.
 | 
					 | 
				
			||||||
!**/[Pp]ackages/build/
 | 
					 | 
				
			||||||
# Uncomment if necessary however generally it will be regenerated when needed
 | 
					 | 
				
			||||||
#!**/[Pp]ackages/repositories.config
 | 
					 | 
				
			||||||
# NuGet v3's project.json files produces more ignorable files
 | 
					 | 
				
			||||||
*.nuget.props
 | 
					 | 
				
			||||||
*.nuget.targets
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Microsoft Azure Build Output
 | 
					 | 
				
			||||||
csx/
 | 
					 | 
				
			||||||
*.build.csdef
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Microsoft Azure Emulator
 | 
					 | 
				
			||||||
ecf/
 | 
					 | 
				
			||||||
rcf/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Windows Store app package directories and files
 | 
					 | 
				
			||||||
AppPackages/
 | 
					 | 
				
			||||||
BundleArtifacts/
 | 
					 | 
				
			||||||
Package.StoreAssociation.xml
 | 
					 | 
				
			||||||
_pkginfo.txt
 | 
					 | 
				
			||||||
*.appx
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Visual Studio cache files
 | 
					 | 
				
			||||||
# files ending in .cache can be ignored
 | 
					 | 
				
			||||||
*.[Cc]ache
 | 
					 | 
				
			||||||
# but keep track of directories ending in .cache
 | 
					 | 
				
			||||||
!*.[Cc]ache/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Others
 | 
					 | 
				
			||||||
ClientBin/
 | 
					 | 
				
			||||||
~$*
 | 
					 | 
				
			||||||
*~
 | 
					 | 
				
			||||||
*.dbmdl
 | 
					 | 
				
			||||||
*.dbproj.schemaview
 | 
					 | 
				
			||||||
*.jfm
 | 
					 | 
				
			||||||
*.pfx
 | 
					 | 
				
			||||||
*.publishsettings
 | 
					 | 
				
			||||||
orleans.codegen.cs
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Since there are multiple workflows, uncomment next line to ignore bower_components
 | 
					 | 
				
			||||||
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
 | 
					 | 
				
			||||||
#bower_components/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# RIA/Silverlight projects
 | 
					 | 
				
			||||||
Generated_Code/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Backup & report files from converting an old project file
 | 
					 | 
				
			||||||
# to a newer Visual Studio version. Backup files are not needed,
 | 
					 | 
				
			||||||
# because we have git ;-)
 | 
					 | 
				
			||||||
_UpgradeReport_Files/
 | 
					 | 
				
			||||||
Backup*/
 | 
					 | 
				
			||||||
UpgradeLog*.XML
 | 
					 | 
				
			||||||
UpgradeLog*.htm
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# SQL Server files
 | 
					 | 
				
			||||||
*.mdf
 | 
					 | 
				
			||||||
*.ldf
 | 
					 | 
				
			||||||
*.ndf
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Business Intelligence projects
 | 
					 | 
				
			||||||
*.rdl.data
 | 
					 | 
				
			||||||
*.bim.layout
 | 
					 | 
				
			||||||
*.bim_*.settings
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Microsoft Fakes
 | 
					 | 
				
			||||||
FakesAssemblies/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# GhostDoc plugin setting file
 | 
					 | 
				
			||||||
*.GhostDoc.xml
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Node.js Tools for Visual Studio
 | 
					 | 
				
			||||||
.ntvs_analysis.dat
 | 
					 | 
				
			||||||
node_modules/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Typescript v1 declaration files
 | 
					 | 
				
			||||||
typings/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Visual Studio 6 build log
 | 
					 | 
				
			||||||
*.plg
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Visual Studio 6 workspace options file
 | 
					 | 
				
			||||||
*.opt
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
 | 
					 | 
				
			||||||
*.vbw
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Visual Studio LightSwitch build output
 | 
					 | 
				
			||||||
**/*.HTMLClient/GeneratedArtifacts
 | 
					 | 
				
			||||||
**/*.DesktopClient/GeneratedArtifacts
 | 
					 | 
				
			||||||
**/*.DesktopClient/ModelManifest.xml
 | 
					 | 
				
			||||||
**/*.Server/GeneratedArtifacts
 | 
					 | 
				
			||||||
**/*.Server/ModelManifest.xml
 | 
					 | 
				
			||||||
_Pvt_Extensions
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Paket dependency manager
 | 
					 | 
				
			||||||
.paket/paket.exe
 | 
					 | 
				
			||||||
paket-files/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# FAKE - F# Make
 | 
					 | 
				
			||||||
.fake/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# JetBrains Rider
 | 
					 | 
				
			||||||
.idea/
 | 
					 | 
				
			||||||
*.sln.iml
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# IDE - VSCode
 | 
					 | 
				
			||||||
.vscode/*
 | 
					 | 
				
			||||||
!.vscode/settings.json
 | 
					 | 
				
			||||||
!.vscode/tasks.json
 | 
					 | 
				
			||||||
!.vscode/launch.json
 | 
					 | 
				
			||||||
!.vscode/extensions.json
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# CodeRush
 | 
					 | 
				
			||||||
.cr/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Python Tools for Visual Studio (PTVS)
 | 
					 | 
				
			||||||
__pycache__/
 | 
					 | 
				
			||||||
*.pyc
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Cake - Uncomment if you are using it
 | 
					 | 
				
			||||||
# tools/**
 | 
					 | 
				
			||||||
# !tools/packages.config
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Tabs Studio
 | 
					 | 
				
			||||||
*.tss
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Telerik's JustMock configuration file
 | 
					 | 
				
			||||||
*.jmconfig
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# BizTalk build output
 | 
					 | 
				
			||||||
*.btp.cs
 | 
					 | 
				
			||||||
*.btm.cs
 | 
					 | 
				
			||||||
*.odx.cs
 | 
					 | 
				
			||||||
*.xsd.cs
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# OpenCover UI analysis results
 | 
					 | 
				
			||||||
OpenCover/
 | 
					 | 
				
			||||||
coverage/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
### macOS template
 | 
					 | 
				
			||||||
# General
 | 
					 | 
				
			||||||
.DS_Store
 | 
					 | 
				
			||||||
.AppleDouble
 | 
					 | 
				
			||||||
.LSOverride
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Icon must end with two \r
 | 
					 | 
				
			||||||
Icon
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Thumbnails
 | 
					 | 
				
			||||||
._*
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Files that might appear in the root of a volume
 | 
					 | 
				
			||||||
.DocumentRevisions-V100
 | 
					 | 
				
			||||||
.fseventsd
 | 
					 | 
				
			||||||
.Spotlight-V100
 | 
					 | 
				
			||||||
.TemporaryItems
 | 
					 | 
				
			||||||
.Trashes
 | 
					 | 
				
			||||||
.VolumeIcon.icns
 | 
					 | 
				
			||||||
.com.apple.timemachine.donotpresent
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Directories potentially created on remote AFP share
 | 
					 | 
				
			||||||
.AppleDB
 | 
					 | 
				
			||||||
.AppleDesktop
 | 
					 | 
				
			||||||
Network Trash Folder
 | 
					 | 
				
			||||||
Temporary Items
 | 
					 | 
				
			||||||
.apdisk
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
=======
 | 
					 | 
				
			||||||
# Local
 | 
					 | 
				
			||||||
.env
 | 
					 | 
				
			||||||
dist
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
files
 | 
					 | 
				
			||||||
sqlite.db
 | 
					 | 
				
			||||||
@@ -1,7 +0,0 @@
 | 
				
			|||||||
{
 | 
					 | 
				
			||||||
	"tabWidth": 4,
 | 
					 | 
				
			||||||
	"useTabs": true,
 | 
					 | 
				
			||||||
	"singleQuote": true,
 | 
					 | 
				
			||||||
	"trailingComma": "none",
 | 
					 | 
				
			||||||
	"endOfLine": "lf"
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@@ -1,19 +0,0 @@
 | 
				
			|||||||
# Mutzi's fileserver
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
## Description
 | 
					 | 
				
			||||||
The most crackhead fileserver you will find on the market
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
## Installation
 | 
					 | 
				
			||||||
```bash
 | 
					 | 
				
			||||||
npm install
 | 
					 | 
				
			||||||
cd frontend && npm install
 | 
					 | 
				
			||||||
```
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
## Running the app
 | 
					 | 
				
			||||||
```bash
 | 
					 | 
				
			||||||
npm run start:dev
 | 
					 | 
				
			||||||
```
 | 
					 | 
				
			||||||
Run in parallel for building the frontend:
 | 
					 | 
				
			||||||
````bash
 | 
					 | 
				
			||||||
cd frontend && npm run serve
 | 
					 | 
				
			||||||
````
 | 
					 | 
				
			||||||
@@ -1,9 +0,0 @@
 | 
				
			|||||||
{
 | 
					 | 
				
			||||||
	"$schema": "https://json.schemastore.org/nest-cli",
 | 
					 | 
				
			||||||
	"collection": "@nestjs/schematics",
 | 
					 | 
				
			||||||
	"monorepo": true,
 | 
					 | 
				
			||||||
	"sourceRoot": "src",
 | 
					 | 
				
			||||||
	"compilerOptions": {
 | 
					 | 
				
			||||||
		"tsConfigPath": "tsconfig.json"
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@@ -1,122 +0,0 @@
 | 
				
			|||||||
{
 | 
					 | 
				
			||||||
	"name": "fileserver",
 | 
					 | 
				
			||||||
	"private": true,
 | 
					 | 
				
			||||||
	"version": "1.0.0",
 | 
					 | 
				
			||||||
	"description": "Crackhead fileserver",
 | 
					 | 
				
			||||||
	"license": "MIT",
 | 
					 | 
				
			||||||
	"scripts": {
 | 
					 | 
				
			||||||
		"prebuild": "rimraf dist",
 | 
					 | 
				
			||||||
		"build": "nest build",
 | 
					 | 
				
			||||||
		"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
 | 
					 | 
				
			||||||
		"start": "nest start",
 | 
					 | 
				
			||||||
		"start:dev": "nest start --watch",
 | 
					 | 
				
			||||||
		"lint": "eslint \"src/**/*.ts\"",
 | 
					 | 
				
			||||||
		"lint-fix": "eslint \"src/**/*.ts\" --fix",
 | 
					 | 
				
			||||||
		"test": "jest",
 | 
					 | 
				
			||||||
		"test:watch": "jest --watch",
 | 
					 | 
				
			||||||
		"test:cov": "jest --coverage",
 | 
					 | 
				
			||||||
		"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
 | 
					 | 
				
			||||||
		"test:e2e": "jest --config ./test/jest-e2e.json",
 | 
					 | 
				
			||||||
		"genapi": "ts-node tools/apigen.ts",
 | 
					 | 
				
			||||||
		"updateDto": "cd dto && yarn build && cd .. && yarn add ./dto && cd frontend && yarn add ../dto",
 | 
					 | 
				
			||||||
		"lint-fix-all": "yarn lint-fix && cd dto && yarn lint-fix && cd ../frontend && yarn lint --fix"
 | 
					 | 
				
			||||||
	},
 | 
					 | 
				
			||||||
	"dependencies": {
 | 
					 | 
				
			||||||
		"@fastify/multipart": "^7.1.0",
 | 
					 | 
				
			||||||
		"@fastify/static": "^6.5.0",
 | 
					 | 
				
			||||||
		"@nestjs/common": "^9.0.8",
 | 
					 | 
				
			||||||
		"@nestjs/core": "^9.0.8",
 | 
					 | 
				
			||||||
		"@nestjs/jwt": "^9.0.0",
 | 
					 | 
				
			||||||
		"@nestjs/passport": "^9.0.0",
 | 
					 | 
				
			||||||
		"@nestjs/platform-fastify": "^9.0.8",
 | 
					 | 
				
			||||||
		"@nestjs/serve-static": "^3.0.0",
 | 
					 | 
				
			||||||
		"@nestjs/typeorm": "^9.0.0",
 | 
					 | 
				
			||||||
		"argon2": "^0.28.7",
 | 
					 | 
				
			||||||
		"axios": "^0.27.2",
 | 
					 | 
				
			||||||
		"class-transformer": "^0.5.1",
 | 
					 | 
				
			||||||
		"class-validator": "^0.13.2",
 | 
					 | 
				
			||||||
		"jsonwebtoken": "^8.5.1",
 | 
					 | 
				
			||||||
		"nodemailer": "^6.7.8",
 | 
					 | 
				
			||||||
		"notp": "^2.0.3",
 | 
					 | 
				
			||||||
		"passport": "^0.6.0",
 | 
					 | 
				
			||||||
		"passport-jwt": "^4.0.0",
 | 
					 | 
				
			||||||
		"passport-local": "^1.0.0",
 | 
					 | 
				
			||||||
		"qrcode": "^1.5.1",
 | 
					 | 
				
			||||||
		"reflect-metadata": "^0.1.13",
 | 
					 | 
				
			||||||
		"rxjs": "^7.5.6",
 | 
					 | 
				
			||||||
		"sqlite3": "^5.0.11",
 | 
					 | 
				
			||||||
		"thirty-two": "^1.0.2",
 | 
					 | 
				
			||||||
		"typeorm": "^0.3.7"
 | 
					 | 
				
			||||||
	},
 | 
					 | 
				
			||||||
	"runtimeDependencies": [
 | 
					 | 
				
			||||||
		"@fastify/multipart",
 | 
					 | 
				
			||||||
		"@fastify/static",
 | 
					 | 
				
			||||||
		"@nestjs/common",
 | 
					 | 
				
			||||||
		"@nestjs/core",
 | 
					 | 
				
			||||||
		"@nestjs/platform-fastify",
 | 
					 | 
				
			||||||
		"@nestjs/serve-static",
 | 
					 | 
				
			||||||
		"argon2",
 | 
					 | 
				
			||||||
		"class-transformer",
 | 
					 | 
				
			||||||
		"class-validator",
 | 
					 | 
				
			||||||
		"reflect-metadata",
 | 
					 | 
				
			||||||
		"rxjs",
 | 
					 | 
				
			||||||
		"sqlite3",
 | 
					 | 
				
			||||||
		"typeorm"
 | 
					 | 
				
			||||||
	],
 | 
					 | 
				
			||||||
	"devDependencies": {
 | 
					 | 
				
			||||||
		"@nestjs/cli": "^9.0.0",
 | 
					 | 
				
			||||||
		"@nestjs/schematics": "^9.0.1",
 | 
					 | 
				
			||||||
		"@nestjs/testing": "^9.0.8",
 | 
					 | 
				
			||||||
		"@types/express": "^4.17.13",
 | 
					 | 
				
			||||||
		"@types/jest": "^28.1.6",
 | 
					 | 
				
			||||||
		"@types/jsonwebtoken": "^8.5.8",
 | 
					 | 
				
			||||||
		"@types/node": "^18.6.5",
 | 
					 | 
				
			||||||
		"@types/nodemailer": "^6.4.5",
 | 
					 | 
				
			||||||
		"@types/notp": "^2.0.2",
 | 
					 | 
				
			||||||
		"@types/passport-jwt": "^3.0.6",
 | 
					 | 
				
			||||||
		"@types/passport-local": "^1.0.34",
 | 
					 | 
				
			||||||
		"@types/qrcode": "^1.5.0",
 | 
					 | 
				
			||||||
		"@types/supertest": "^2.0.12",
 | 
					 | 
				
			||||||
		"@types/webpack": "^5.28.0",
 | 
					 | 
				
			||||||
		"@types/webpack-node-externals": "^2.5.3",
 | 
					 | 
				
			||||||
		"@typescript-eslint/eslint-plugin": "^5.33.0",
 | 
					 | 
				
			||||||
		"@typescript-eslint/parser": "^5.33.0",
 | 
					 | 
				
			||||||
		"@typescript-eslint/typescript-estree": "^5.33.0",
 | 
					 | 
				
			||||||
		"copy-webpack-plugin": "^11.0.0",
 | 
					 | 
				
			||||||
		"eslint": "^8.21.0",
 | 
					 | 
				
			||||||
		"eslint-config-prettier": "^8.5.0",
 | 
					 | 
				
			||||||
		"eslint-plugin-no-relative-import-paths": "^1.4.0",
 | 
					 | 
				
			||||||
		"eslint-plugin-prettier": "^4.2.1",
 | 
					 | 
				
			||||||
		"jest": "^28.1.3",
 | 
					 | 
				
			||||||
		"prettier": "^2.7.1",
 | 
					 | 
				
			||||||
		"rimraf": "^3.0.2",
 | 
					 | 
				
			||||||
		"source-map-support": "^0.5.21",
 | 
					 | 
				
			||||||
		"supertest": "^6.2.4",
 | 
					 | 
				
			||||||
		"ts-jest": "^28.0.7",
 | 
					 | 
				
			||||||
		"ts-loader": "^9.3.1",
 | 
					 | 
				
			||||||
		"ts-node": "^10.9.1",
 | 
					 | 
				
			||||||
		"tsconfig-paths": "^4.1.0",
 | 
					 | 
				
			||||||
		"tsconfig-paths-webpack-plugin": "^4.0.0",
 | 
					 | 
				
			||||||
		"typescript": "^4.7.4",
 | 
					 | 
				
			||||||
		"webpack": "^5.74.0",
 | 
					 | 
				
			||||||
		"webpack-cli": "^4.10.0",
 | 
					 | 
				
			||||||
		"webpack-node-externals": "^3.0.0"
 | 
					 | 
				
			||||||
	},
 | 
					 | 
				
			||||||
	"jest": {
 | 
					 | 
				
			||||||
		"moduleFileExtensions": [
 | 
					 | 
				
			||||||
			"js",
 | 
					 | 
				
			||||||
			"json",
 | 
					 | 
				
			||||||
			"ts"
 | 
					 | 
				
			||||||
		],
 | 
					 | 
				
			||||||
		"rootDir": "src",
 | 
					 | 
				
			||||||
		"testRegex": ".*\\.spec\\.ts$",
 | 
					 | 
				
			||||||
		"transform": {
 | 
					 | 
				
			||||||
			"^.+\\.(t|j)s$": "ts-jest"
 | 
					 | 
				
			||||||
		},
 | 
					 | 
				
			||||||
		"collectCoverageFrom": [
 | 
					 | 
				
			||||||
			"**/*.(t|j)s"
 | 
					 | 
				
			||||||
		],
 | 
					 | 
				
			||||||
		"coverageDirectory": "../coverage",
 | 
					 | 
				
			||||||
		"testEnvironment": "node"
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@@ -1,36 +0,0 @@
 | 
				
			|||||||
### Create account
 | 
					 | 
				
			||||||
POST http://127.0.0.1:8080/api/auth/signup
 | 
					 | 
				
			||||||
Content-Type: application/json
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
{"username": "root@mattv.de", "password": "123"}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
### Wrong authenctication
 | 
					 | 
				
			||||||
POST http://127.0.0.1:8080/api/auth/login
 | 
					 | 
				
			||||||
Content-Type: application/json
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
{"username": "root@mattv.de", "password": "this is not correct"}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
### Correct authentication
 | 
					 | 
				
			||||||
POST http://127.0.0.1:8080/api/auth/login
 | 
					 | 
				
			||||||
Content-Type: application/json
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
{"username": "root@mattv.de", "password": "123"}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
> {% client.global.set("auth_token", response.body.jwt); %}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
### Check if authenticated with admin perms
 | 
					 | 
				
			||||||
GET http://127.0.0.1:8080/test/hello2
 | 
					 | 
				
			||||||
Authorization: Bearer {{auth_token}}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
### Refresh token
 | 
					 | 
				
			||||||
POST http://127.0.0.1:8080/api/auth/refresh
 | 
					 | 
				
			||||||
Authorization: Bearer {{auth_token}}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
### A
 | 
					 | 
				
			||||||
POST https://ssh.gitlab.mattv.de/oauth/token
 | 
					 | 
				
			||||||
?redirect_uri=http%3A//127.0.0.1%3A1234/api/auth/gitlab_callback
 | 
					 | 
				
			||||||
&client_id=98bcbad78cb1f880d1d1de62291d70a791251a7bea077bfe7df111ef3c115760
 | 
					 | 
				
			||||||
&client_secret=7ee01d2b204aff3a05f9d028f004d169b6d381ec873e195f314b3935fa150959
 | 
					 | 
				
			||||||
&code=b96f91b171cf23245ea08c6f35c3831698e8683c6d0306de1396507f0f51d4c7
 | 
					 | 
				
			||||||
&grant_type=authorization_code
 | 
					 | 
				
			||||||
@@ -1,28 +0,0 @@
 | 
				
			|||||||
import {
 | 
					 | 
				
			||||||
	Body,
 | 
					 | 
				
			||||||
	Controller,
 | 
					 | 
				
			||||||
	Get,
 | 
					 | 
				
			||||||
	Param,
 | 
					 | 
				
			||||||
	ParseIntPipe,
 | 
					 | 
				
			||||||
	Post,
 | 
					 | 
				
			||||||
	Request,
 | 
					 | 
				
			||||||
	StreamableFile,
 | 
					 | 
				
			||||||
	ValidationPipe
 | 
					 | 
				
			||||||
} from '@nestjs/common';
 | 
					 | 
				
			||||||
import { Responses, Requests, validateAsyncInline, UserRole } from '../../dto';
 | 
					 | 
				
			||||||
import FileSystemService from 'services/filesystem';
 | 
					 | 
				
			||||||
import { Role } from 'authguards';
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
@Controller('api/fs')
 | 
					 | 
				
			||||||
export default class FileSystemController {
 | 
					 | 
				
			||||||
	constructor(private fsService: FileSystemService) {}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	@Post('download')
 | 
					 | 
				
			||||||
	@Role(UserRole.USER)
 | 
					 | 
				
			||||||
	async download(
 | 
					 | 
				
			||||||
		@Request() req,
 | 
					 | 
				
			||||||
		@Body('id', ParseIntPipe) id
 | 
					 | 
				
			||||||
	): Promise<StreamableFile> {
 | 
					 | 
				
			||||||
		return this.fsService.downloadFile(id, req.user);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@@ -1,32 +0,0 @@
 | 
				
			|||||||
import {
 | 
					 | 
				
			||||||
	BadRequestException,
 | 
					 | 
				
			||||||
	Injectable,
 | 
					 | 
				
			||||||
	NotImplementedException,
 | 
					 | 
				
			||||||
	StreamableFile,
 | 
					 | 
				
			||||||
	UnauthorizedException
 | 
					 | 
				
			||||||
} from '@nestjs/common';
 | 
					 | 
				
			||||||
import { InjectRepository } from '@nestjs/typeorm';
 | 
					 | 
				
			||||||
import { INode, User } from 'entities';
 | 
					 | 
				
			||||||
import { Repository } from 'typeorm';
 | 
					 | 
				
			||||||
import { Multipart } from '@fastify/multipart';
 | 
					 | 
				
			||||||
import { pipeline } from 'stream/promises';
 | 
					 | 
				
			||||||
import { createReadStream, createWriteStream, statSync, unlink } from 'fs';
 | 
					 | 
				
			||||||
import { Writable } from 'stream';
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
@Injectable()
 | 
					 | 
				
			||||||
export default class FileSystemService {
 | 
					 | 
				
			||||||
	constructor(
 | 
					 | 
				
			||||||
		@InjectRepository(INode)
 | 
					 | 
				
			||||||
		private inodeRepo: Repository<INode>
 | 
					 | 
				
			||||||
	) {}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	async downloadFile(id: number, user: User): Promise<StreamableFile> {
 | 
					 | 
				
			||||||
		const node = await this.getNodeAndValidate(id, user);
 | 
					 | 
				
			||||||
		if (!node.isFile) throw new NotImplementedException();
 | 
					 | 
				
			||||||
		const stats = statSync(`files/${node.id}`);
 | 
					 | 
				
			||||||
		return new StreamableFile(createReadStream(`files/${node.id}`), {
 | 
					 | 
				
			||||||
			disposition: `attachment; filename="${node.name}"`,
 | 
					 | 
				
			||||||
			length: stats.size
 | 
					 | 
				
			||||||
		});
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@@ -1,306 +0,0 @@
 | 
				
			|||||||
import {
 | 
					 | 
				
			||||||
	AST_NODE_TYPES,
 | 
					 | 
				
			||||||
	createProgram,
 | 
					 | 
				
			||||||
	parse
 | 
					 | 
				
			||||||
} from '@typescript-eslint/typescript-estree';
 | 
					 | 
				
			||||||
import * as fs from 'fs';
 | 
					 | 
				
			||||||
import * as path from 'path';
 | 
					 | 
				
			||||||
import * as a from '@typescript-eslint/types/dist/generated/ast-spec';
 | 
					 | 
				
			||||||
import { TypeNode } from '@typescript-eslint/types/dist/generated/ast-spec';
 | 
					 | 
				
			||||||
import { Writable } from 'stream';
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
class Err extends Error {
 | 
					 | 
				
			||||||
	constructor(o: object) {
 | 
					 | 
				
			||||||
		super();
 | 
					 | 
				
			||||||
		console.error(o);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
const program = createProgram('tsconfig.json');
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
class BetterWritable {
 | 
					 | 
				
			||||||
	constructor(private w: Writable) {}
 | 
					 | 
				
			||||||
	private indent = 0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	write(data: string) {
 | 
					 | 
				
			||||||
		this.w.write('\t'.repeat(this.indent));
 | 
					 | 
				
			||||||
		this.w.write(data);
 | 
					 | 
				
			||||||
		this.w.write('\n');
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	writeInc(data: string) {
 | 
					 | 
				
			||||||
		this.write(data);
 | 
					 | 
				
			||||||
		this.indent++;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	writeDec(data: string) {
 | 
					 | 
				
			||||||
		this.indent--;
 | 
					 | 
				
			||||||
		this.write(data);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	writeDecInc(data: string) {
 | 
					 | 
				
			||||||
		this.indent--;
 | 
					 | 
				
			||||||
		this.write(data);
 | 
					 | 
				
			||||||
		this.indent++;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
interface Outputable {
 | 
					 | 
				
			||||||
	write(s: BetterWritable);
 | 
					 | 
				
			||||||
	writeJsonAs(ns: string, s: BetterWritable);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
class CppProp {
 | 
					 | 
				
			||||||
	constructor(entry: string) {
 | 
					 | 
				
			||||||
		this.entry = entry;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	entry: string;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// template <> inline dto::Requests::Auth::LoginRequest Json::Value::as<dto::Requests::Auth::LoginRequest>() const { return asFloat(); }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
class CppClass implements Outputable {
 | 
					 | 
				
			||||||
	constructor(name: string) {
 | 
					 | 
				
			||||||
		this.name = name;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	type = 'class' as const;
 | 
					 | 
				
			||||||
	name: string;
 | 
					 | 
				
			||||||
	sub: string[] = [];
 | 
					 | 
				
			||||||
	entries: CppProp[] = [];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	write(s: BetterWritable) {
 | 
					 | 
				
			||||||
		let name = `struct ${this.name}`;
 | 
					 | 
				
			||||||
		if (this.sub.length > 0)
 | 
					 | 
				
			||||||
			name += ' : public ' + this.sub.join(', public ');
 | 
					 | 
				
			||||||
		s.writeInc(`${name} {`);
 | 
					 | 
				
			||||||
		if (this.sub.length == 0) {
 | 
					 | 
				
			||||||
			s.write(`${this.name}() = default;`);
 | 
					 | 
				
			||||||
			s.writeInc(`explicit ${this.name}(const Json::Value& j) {`);
 | 
					 | 
				
			||||||
		} else {
 | 
					 | 
				
			||||||
			s.writeInc(`${this.name}() :`);
 | 
					 | 
				
			||||||
			this.sub.forEach((sub) => {
 | 
					 | 
				
			||||||
				s.write(`${sub}()`);
 | 
					 | 
				
			||||||
			});
 | 
					 | 
				
			||||||
			s.writeDec('{}');
 | 
					 | 
				
			||||||
			s.writeInc(`explicit ${this.name}(const Json::Value& j) :`);
 | 
					 | 
				
			||||||
			this.sub.forEach((sub) => {
 | 
					 | 
				
			||||||
				s.write(`${sub}(j)`);
 | 
					 | 
				
			||||||
			});
 | 
					 | 
				
			||||||
			s.writeDecInc('{');
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		this.entries.forEach((e) => {
 | 
					 | 
				
			||||||
			const [type, name] = e.entry.split(' ');
 | 
					 | 
				
			||||||
			const opt_match = /std::optional<([a-z:<>]+)>/.exec(type);
 | 
					 | 
				
			||||||
			if (opt_match !== null)
 | 
					 | 
				
			||||||
				s.write(
 | 
					 | 
				
			||||||
					`this->${name} = json_get_optional<${opt_match[1]}>(j, "${name}");`
 | 
					 | 
				
			||||||
				);
 | 
					 | 
				
			||||||
			else s.write(`this->${name} = j["${name}"].as<${type}>();`);
 | 
					 | 
				
			||||||
		});
 | 
					 | 
				
			||||||
		s.writeDec('}');
 | 
					 | 
				
			||||||
		this.entries.forEach((e) => s.write(`${e.entry};`));
 | 
					 | 
				
			||||||
		s.writeDec('};');
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	writeJsonAs(ns: string, s: BetterWritable) {
 | 
					 | 
				
			||||||
		s.write(
 | 
					 | 
				
			||||||
			`template <> inline ${ns}${this.name} Json::Value::as() const { return ${ns}${this.name}(*this); }`
 | 
					 | 
				
			||||||
		);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
class CppEnum implements Outputable {
 | 
					 | 
				
			||||||
	constructor(name: string) {
 | 
					 | 
				
			||||||
		this.name = name;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	type = 'enum' as const;
 | 
					 | 
				
			||||||
	name: string;
 | 
					 | 
				
			||||||
	entries: CppProp[] = [];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	write(s: BetterWritable) {
 | 
					 | 
				
			||||||
		return;
 | 
					 | 
				
			||||||
		s.writeInc(`enum ${this.name} : int {`);
 | 
					 | 
				
			||||||
		this.entries.forEach((e, idx, arr) =>
 | 
					 | 
				
			||||||
			s.write(`${e.entry}${idx === arr.length - 1 ? '' : ','}`)
 | 
					 | 
				
			||||||
		);
 | 
					 | 
				
			||||||
		s.writeDec('};');
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	writeJsonAs(ns: string, s: BetterWritable) {
 | 
					 | 
				
			||||||
		return;
 | 
					 | 
				
			||||||
		s.write(
 | 
					 | 
				
			||||||
			`template <> inline ${ns}${this.name} Json::Value::as() const { return (${ns}${this.name})(asInt()); }`
 | 
					 | 
				
			||||||
		);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
class CppNamespace implements Outputable {
 | 
					 | 
				
			||||||
	constructor(name: string) {
 | 
					 | 
				
			||||||
		this.name = name;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	type = 'ns' as const;
 | 
					 | 
				
			||||||
	name: string;
 | 
					 | 
				
			||||||
	body: (CppNamespace | CppClass | CppEnum)[] = [];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	write(s: BetterWritable) {
 | 
					 | 
				
			||||||
		s.writeInc(`namespace ${this.name} {`);
 | 
					 | 
				
			||||||
		this.body.forEach((b) => b.write(s));
 | 
					 | 
				
			||||||
		s.writeDec('}');
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	writeJsonAs(ns: string, s: BetterWritable) {
 | 
					 | 
				
			||||||
		ns += `${this.name}::`;
 | 
					 | 
				
			||||||
		this.body.forEach((b) => b.writeJsonAs(ns, s));
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
function _getCppType(
 | 
					 | 
				
			||||||
	t: TypeNode
 | 
					 | 
				
			||||||
): null | string | ((opt: boolean, name: string) => string) {
 | 
					 | 
				
			||||||
	switch (t.type) {
 | 
					 | 
				
			||||||
		case AST_NODE_TYPES.TSStringKeyword:
 | 
					 | 
				
			||||||
			return 'std::string';
 | 
					 | 
				
			||||||
		case AST_NODE_TYPES.TSBooleanKeyword:
 | 
					 | 
				
			||||||
			return 'bool';
 | 
					 | 
				
			||||||
		case AST_NODE_TYPES.TSNumberKeyword:
 | 
					 | 
				
			||||||
			return 'int';
 | 
					 | 
				
			||||||
		case AST_NODE_TYPES.TSTypeReference:
 | 
					 | 
				
			||||||
			if (t.typeName.type != AST_NODE_TYPES.Identifier) throw new Err(t);
 | 
					 | 
				
			||||||
			return t.typeName.name;
 | 
					 | 
				
			||||||
		case AST_NODE_TYPES.TSLiteralType:
 | 
					 | 
				
			||||||
			return null;
 | 
					 | 
				
			||||||
		case AST_NODE_TYPES.TSUnionType:
 | 
					 | 
				
			||||||
			return _getCppType(t.types[0]);
 | 
					 | 
				
			||||||
		case AST_NODE_TYPES.TSArrayType:
 | 
					 | 
				
			||||||
			return `std::vector<${_getCppType(t.elementType)}>`;
 | 
					 | 
				
			||||||
		default:
 | 
					 | 
				
			||||||
			throw new Err(t);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
function getCppType(opt: boolean, name: string, t: TypeNode): null | string {
 | 
					 | 
				
			||||||
	let ret = _getCppType(t);
 | 
					 | 
				
			||||||
	if (typeof ret === 'function') return `${ret(opt, name)}`;
 | 
					 | 
				
			||||||
	if (typeof ret === 'string') {
 | 
					 | 
				
			||||||
		if (opt) ret = `std::optional<${ret}>`;
 | 
					 | 
				
			||||||
		return `${ret} ${name}`;
 | 
					 | 
				
			||||||
	} else return ret;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
function handleClassProperty(
 | 
					 | 
				
			||||||
	prop: a.PropertyDefinitionComputedName | a.PropertyDefinitionNonComputedName
 | 
					 | 
				
			||||||
): CppProp | null {
 | 
					 | 
				
			||||||
	if (prop.key.type != AST_NODE_TYPES.Identifier) throw new Err(prop);
 | 
					 | 
				
			||||||
	if (!prop.typeAnnotation) throw new Err(prop);
 | 
					 | 
				
			||||||
	const type = getCppType(
 | 
					 | 
				
			||||||
		prop.optional && prop.optional,
 | 
					 | 
				
			||||||
		prop.key.name,
 | 
					 | 
				
			||||||
		prop.typeAnnotation.typeAnnotation
 | 
					 | 
				
			||||||
	);
 | 
					 | 
				
			||||||
	return type === null ? null : new CppProp(type);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
function handleClass(
 | 
					 | 
				
			||||||
	dec: a.ClassDeclarationWithName | a.ClassDeclarationWithOptionalName
 | 
					 | 
				
			||||||
): CppClass {
 | 
					 | 
				
			||||||
	if (!dec.id) throw new Err(dec);
 | 
					 | 
				
			||||||
	const cls = new CppClass(dec.id.name);
 | 
					 | 
				
			||||||
	if (dec.superClass) {
 | 
					 | 
				
			||||||
		const subCls = dec.superClass;
 | 
					 | 
				
			||||||
		if (subCls.type == AST_NODE_TYPES.Identifier) cls.sub.push(subCls.name);
 | 
					 | 
				
			||||||
		else throw new Err(subCls);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	dec.body.body.forEach((inner) => {
 | 
					 | 
				
			||||||
		if (inner.type == AST_NODE_TYPES.PropertyDefinition) {
 | 
					 | 
				
			||||||
			const prop = handleClassProperty(inner);
 | 
					 | 
				
			||||||
			if (prop) cls.entries.push(prop);
 | 
					 | 
				
			||||||
		} else if (
 | 
					 | 
				
			||||||
			inner.type == AST_NODE_TYPES.MethodDefinition &&
 | 
					 | 
				
			||||||
			inner.key.type == AST_NODE_TYPES.Identifier &&
 | 
					 | 
				
			||||||
			inner.key.name === 'constructor'
 | 
					 | 
				
			||||||
		)
 | 
					 | 
				
			||||||
			return;
 | 
					 | 
				
			||||||
		else throw new Err(inner);
 | 
					 | 
				
			||||||
	});
 | 
					 | 
				
			||||||
	return cls;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
function handleEnum(dec: a.TSEnumDeclaration): CppEnum {
 | 
					 | 
				
			||||||
	const enm = new CppEnum(dec.id.name);
 | 
					 | 
				
			||||||
	dec.members.forEach((member) => {
 | 
					 | 
				
			||||||
		if (
 | 
					 | 
				
			||||||
			member.id.type == AST_NODE_TYPES.Identifier &&
 | 
					 | 
				
			||||||
			member.initializer.type == AST_NODE_TYPES.Literal
 | 
					 | 
				
			||||||
		) {
 | 
					 | 
				
			||||||
			enm.entries.push(
 | 
					 | 
				
			||||||
				new CppProp(`${member.id.name} = ${member.initializer.raw}`)
 | 
					 | 
				
			||||||
			);
 | 
					 | 
				
			||||||
		} else throw new Err(member);
 | 
					 | 
				
			||||||
	});
 | 
					 | 
				
			||||||
	return enm;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
function handleNamedDeclaration(
 | 
					 | 
				
			||||||
	dec: a.ExportNamedDeclaration
 | 
					 | 
				
			||||||
): CppClass | CppEnum | undefined {
 | 
					 | 
				
			||||||
	if (!dec.declaration) throw new Err(dec);
 | 
					 | 
				
			||||||
	else if (dec.declaration.type == AST_NODE_TYPES.ClassDeclaration)
 | 
					 | 
				
			||||||
		return handleClass(dec.declaration);
 | 
					 | 
				
			||||||
	else if (dec.declaration.type == AST_NODE_TYPES.TSEnumDeclaration)
 | 
					 | 
				
			||||||
		return handleEnum(dec.declaration);
 | 
					 | 
				
			||||||
	else if (dec.declaration.type == AST_NODE_TYPES.FunctionDeclaration) return;
 | 
					 | 
				
			||||||
	else {
 | 
					 | 
				
			||||||
		throw new Err(dec);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
function handleExport(
 | 
					 | 
				
			||||||
	ns: CppNamespace,
 | 
					 | 
				
			||||||
	file: string,
 | 
					 | 
				
			||||||
	body: a.ExportNamedDeclaration | a.ExportAllDeclaration
 | 
					 | 
				
			||||||
) {
 | 
					 | 
				
			||||||
	let newPath = path.join(path.dirname(file), body.source.value);
 | 
					 | 
				
			||||||
	if (fs.existsSync(newPath) && fs.statSync(newPath).isDirectory())
 | 
					 | 
				
			||||||
		newPath = path.join(newPath, 'index.ts');
 | 
					 | 
				
			||||||
	else if (!newPath.endsWith('.ts')) newPath = newPath + '.ts';
 | 
					 | 
				
			||||||
	console.log(`${file}: ${newPath}`);
 | 
					 | 
				
			||||||
	parseFile(ns, newPath);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
function parseFile(ns: CppNamespace, file: string) {
 | 
					 | 
				
			||||||
	const ast = parse(fs.readFileSync(file).toString(), {
 | 
					 | 
				
			||||||
		programs: [program]
 | 
					 | 
				
			||||||
	});
 | 
					 | 
				
			||||||
	ast.body
 | 
					 | 
				
			||||||
		.filter((body) => body.type == AST_NODE_TYPES.ExportNamedDeclaration)
 | 
					 | 
				
			||||||
		.forEach((body: a.ExportNamedDeclaration) => {
 | 
					 | 
				
			||||||
			if (!body.source) {
 | 
					 | 
				
			||||||
				const ret = handleNamedDeclaration(body);
 | 
					 | 
				
			||||||
				if (ret) ns.body.push(ret);
 | 
					 | 
				
			||||||
			} else handleExport(ns, file, body);
 | 
					 | 
				
			||||||
		});
 | 
					 | 
				
			||||||
	ast.body
 | 
					 | 
				
			||||||
		.filter((body) => body.type == AST_NODE_TYPES.ExportAllDeclaration)
 | 
					 | 
				
			||||||
		.forEach((body: a.ExportAllDeclaration) => {
 | 
					 | 
				
			||||||
			let usedNs = ns;
 | 
					 | 
				
			||||||
			if ('exported' in body && body.exported) {
 | 
					 | 
				
			||||||
				const newNs = new CppNamespace(body.exported.name);
 | 
					 | 
				
			||||||
				ns.body.push(newNs);
 | 
					 | 
				
			||||||
				usedNs = newNs;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			handleExport(usedNs, file, body);
 | 
					 | 
				
			||||||
		});
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
const globalNamespace = new CppNamespace('dto');
 | 
					 | 
				
			||||||
parseFile(globalNamespace, '../dto/index.ts');
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
const output_stream = fs.createWriteStream('../backend/src/dto.h');
 | 
					 | 
				
			||||||
output_stream.write(
 | 
					 | 
				
			||||||
	'#pragma once\n\n' +
 | 
					 | 
				
			||||||
		'#include <string>\n' +
 | 
					 | 
				
			||||||
		'#include <optional>\n' +
 | 
					 | 
				
			||||||
		'#include <vector>\n' +
 | 
					 | 
				
			||||||
		'#include <json/allocator.h>\n' +
 | 
					 | 
				
			||||||
		'#include "dto_extras.h"\n\n'
 | 
					 | 
				
			||||||
);
 | 
					 | 
				
			||||||
const output = new BetterWritable(output_stream);
 | 
					 | 
				
			||||||
globalNamespace.write(output);
 | 
					 | 
				
			||||||
globalNamespace.writeJsonAs('', output);
 | 
					 | 
				
			||||||
@@ -1,19 +0,0 @@
 | 
				
			|||||||
{
 | 
					 | 
				
			||||||
	"compilerOptions": {
 | 
					 | 
				
			||||||
		"module": "commonjs",
 | 
					 | 
				
			||||||
		"declaration": false,
 | 
					 | 
				
			||||||
		"removeComments": true,
 | 
					 | 
				
			||||||
		"emitDecoratorMetadata": true,
 | 
					 | 
				
			||||||
		"experimentalDecorators": true,
 | 
					 | 
				
			||||||
		"allowSyntheticDefaultImports": true,
 | 
					 | 
				
			||||||
		"target": "es2017",
 | 
					 | 
				
			||||||
		"sourceMap": true,
 | 
					 | 
				
			||||||
		"outDir": "./dist",
 | 
					 | 
				
			||||||
		"baseUrl": "./src",
 | 
					 | 
				
			||||||
		"incremental": true,
 | 
					 | 
				
			||||||
		"skipLibCheck": true,
 | 
					 | 
				
			||||||
		"resolveJsonModule": true,
 | 
					 | 
				
			||||||
		"strictPropertyInitialization": false
 | 
					 | 
				
			||||||
	},
 | 
					 | 
				
			||||||
	"exclude": ["node_modules", "dist", "test", "**/*spec.ts", "frontend"]
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
		Reference in New Issue
	
	Block a user