Skip to content

Commit

Permalink
wip: Full refactor of the server to swift with vapor
Browse files Browse the repository at this point in the history
  • Loading branch information
Dracks committed Nov 5, 2024
1 parent 256500d commit 270ed62
Show file tree
Hide file tree
Showing 361 changed files with 60,047 additions and 978 deletions.
1 change: 1 addition & 0 deletions .env.testing
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DB_URL=sqlite://memory
122 changes: 122 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
# server
root: true
env:
es6: true
jest: true
node: true
extends:
- 'eslint:all'
- 'plugin:@typescript-eslint/recommended'
- 'plugin:import/typescript'
- prettier
parser: '@typescript-eslint/parser'
parserOptions:
ecmaVersion: 2021
sourceType: module
createDefaultProgram: true
project: tsconfig.server.json
plugins:
- eslint-plugin-unicorn
- eslint-plugin-import
- simple-import-sort
- '@typescript-eslint'
- typescript-sort-keys
rules:
unicorn/prefer-type-error: 'off'
typescript-sort-keys/interface: warn
typescript-sort-keys/string-enum: warn
'@typescript-eslint/no-floating-promises':
- warn
-
ignoreIIFE: true
max-statements:
- error
- 30
max-params:
- warn
- 6
new-cap: 0
no-console: warn
no-undefined: 'off'
no-warning-comments: 'off'
simple-import-sort/exports:
- error
simple-import-sort/imports:
- error
- groups:
-
- "^@?\\w"
-
- "^(src|lib|test|\\.)"
max-classes-per-file: 'off'
no-underscore-dangle:
- error
-
allow:
- _id
- __v

import/no-unassigned-import: warn
import/order: 'off'
sort-imports: 'off'
sort-keys:
- error
- asc
- natural: true
minKeys: 5
no-useless-constructor: 'off'
no-shadow: off
'@typescript-eslint/no-shadow': warn
'@typescript-eslint/prefer-nullish-coalescing': error
'@typescript-eslint/no-explicit-any': error
'@typescript-eslint/no-useless-constructor': 'off'
no-magic-numbers: 'off'
no-ternary: 'off'
one-var: 'off'
capitalized-comments: 'off'
unicorn/filename-case:
- error
-
case: kebabCase
no-duplicate-imports: warn
unicorn/no-abusive-eslint-disable: warn
'@typescript-eslint/no-unnecessary-type-constraint': warn
overrides:
-
files:
- '*.{e2e-spec,int-spec,test,spec}.{js,jsx,ts,tsx}'
rules:
max-lines: 'off'
init-declarations: 'off'
unicorn/consistent-function-scoping: 'off'
'@typescript-eslint/no-explicit-any': 'off'
max-lines-per-function: 'off'
-
files:
- '*.{jsx,tsx}'
extends:
- 'plugin:prettier/recommended'
plugins:
- '@typescript-eslint'
- simple-import-sort
- typescript-sort-keys
env:
jest: true
node: true
rules:
id-length:
- error
-
min: 1
typescript-sort-keys/interface: warn
typescript-sort-keys/string-enum: warn
'@typescript-eslint/no-unused-vars': error
prettier/prettier:
- error
-
singleQuote: true
tabWidth: 4
printWidth: 120
trailingComma: "all"
arrowParens: "avoid"
endOfLine: auto
36 changes: 0 additions & 36 deletions .github/workflows/test-server.yml

This file was deleted.

21 changes: 21 additions & 0 deletions .github/workflows/test-swift.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: test
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
push:
branches:
- main
- to-swift

jobs:
test:
name: Test
runs-on: ubuntu-latest
container: swift:5.10
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Run tests
run: swift test --parallel
# run: swift test
52 changes: 24 additions & 28 deletions .github/workflows/test-view.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,47 +5,43 @@ name: Node.js Package

on: [pull_request]

defaults:
run:
working-directory: view

env:
NODE_VERSION: 16
NODE_VERSION: 20

jobs:
test:
name: Test View
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: pnpm/action-setup@v4
name: Install pnpm
with:
node-version: ${{ env.NODE_VERSION }}
- name: Cache node_modules
id: npm-cache
uses: actions/cache@v3
run_install: false

- name: Install Node.js
uses: actions/setup-node@v4
with:
path: ./node_modules
key: npm-${{ env.NODE_VERSION }}-${{ hashFiles('package-lock.json') }}
restore-keys: npm-${{ env.NODE_VERSION }}-
- run: npm ci
if: steps.npm-cache.outputs.cache-hit != 'true'
- run: npm test
node-version: ${{ env.NODE_VERSION }}
cache: 'pnpm'

- run: pnpm install
- run: pnpm run test:view
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: pnpm/action-setup@v4
name: Install pnpm
with:
node-version: ${{ env.NODE_VERSION }}
- name: Cache node_modules
id: npm-cache
uses: actions/cache@v3
run_install: false

- name: Install Node.js
uses: actions/setup-node@v4
with:
path: ./node_modules
key: npm-${{ env.NODE_VERSION }}-${{ hashFiles('package-lock.json') }}
restore-keys: npm-${{ env.NODE_VERSION }}-
- run: npm install
if: steps.npm-cache.outputs.cache-hit != 'true'
- run: npm run lint
node-version: ${{ env.NODE_VERSION }}
cache: 'pnpm'

- run: pnpm install
- run: pnpm run lint
14 changes: 11 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
node_modules

# testing
/coverage
coverage

# production
build
Public/react
Resources/Views/react.leaf

# misc
.DS_Store
Expand All @@ -25,6 +26,13 @@ __pycache__
migrations/*.py


server/db.sqlite3
db.sqlite3
server/finances/templates/react.html
server/static/react

# swift
.build
.swiftpm
Resources/Views/react.leaf
Public/react

69 changes: 69 additions & 0 deletions .swift-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{
"fileScopedDeclarationPrivacy" : {
"accessLevel" : "private"
},
"indentation" : {
"tabs" : 1
},
"indentConditionalCompilationBlocks" : true,
"indentSwitchCaseLabels" : false,
"lineBreakAroundMultilineExpressionChainComponents" : false,
"lineBreakBeforeControlFlowKeywords" : false,
"lineBreakBeforeEachArgument" : false,
"lineBreakBeforeEachGenericRequirement" : false,
"lineLength" : 100,
"maximumBlankLines" : 1,
"multiElementCollectionTrailingCommas" : true,
"noAssignmentInExpressions" : {
"allowedFunctions" : [
"XCTAssertNoThrow"
]
},
"prioritizeKeepingFunctionOutputTogether" : false,
"respectsExistingLineBreaks" : true,
"rules" : {
"AllPublicDeclarationsHaveDocumentation" : false,
"AlwaysUseLiteralForEmptyCollectionInit" : false,
"AlwaysUseLowerCamelCase" : true,
"AmbiguousTrailingClosureOverload" : true,
"BeginDocumentationCommentWithOneLineSummary" : false,
"DoNotUseSemicolons" : true,
"DontRepeatTypeInStaticProperties" : true,
"FileScopedDeclarationPrivacy" : true,
"FullyIndirectEnum" : true,
"GroupNumericLiterals" : true,
"IdentifiersMustBeASCII" : true,
"NeverForceUnwrap" : false,
"NeverUseForceTry" : false,
"NeverUseImplicitlyUnwrappedOptionals" : false,
"NoAccessLevelOnExtensionDeclaration" : true,
"NoAssignmentInExpressions" : true,
"NoBlockComments" : true,
"NoCasesWithOnlyFallthrough" : true,
"NoEmptyTrailingClosureParentheses" : true,
"NoLabelsInCasePatterns" : true,
"NoLeadingUnderscores" : false,
"NoParensAroundConditions" : true,
"NoPlaygroundLiterals" : true,
"NoVoidReturnOnFunctionSignature" : true,
"OmitExplicitReturns" : false,
"OneCasePerLine" : true,
"OneVariableDeclarationPerLine" : true,
"OnlyOneTrailingClosureArgument" : true,
"OrderedImports" : true,
"ReplaceForEachWithForLoop" : true,
"ReturnVoidInsteadOfEmptyTuple" : true,
"TypeNamesShouldBeCapitalized" : true,
"UseEarlyExits" : false,
"UseLetInEveryBoundCaseVariable" : true,
"UseShorthandTypeNames" : true,
"UseSingleLinePropertyGetter" : true,
"UseSynthesizedInitializer" : true,
"UseTripleSlashForDocumentationComments" : true,
"UseWhereClausesInForLoops" : false,
"ValidateDocumentationComments" : false
},
"spacesAroundRangeFormationOperators" : false,
"tabWidth" : 8,
"version" : 1
}
Loading

0 comments on commit 270ed62

Please sign in to comment.