diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 4f37f05..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,67 +0,0 @@ -version: 2 -jobs: - MacOS: - macos: - xcode: "9.3.0" - steps: - - checkout - - restore_cache: - keys: - - v3-spm-deps-{{ checksum "Package.swift" }} - - run: - name: Install CMySQL and CTLS - command: | - export HOMEBREW_NO_AUTO_UPDATE=1 - brew tap vapor/homebrew-tap - brew install cmysql - brew install ctls - brew install libressl - - run: - name: Build and Run Tests - no_output_timeout: 1800 - command: | - swift package generate-xcodeproj --enable-code-coverage - xcodebuild -scheme JWTKeychain-Package -enableCodeCoverage YES test | xcpretty - - run: - name: Report coverage to Codecov - command: | - bash <(curl -s https://codecov.io/bash) - - save_cache: - key: v1-spm-deps-{{ checksum "Package.swift" }} - paths: - - .build - Linux: - docker: - - image: nodesvapor/vapor-ci:swift-4.1 - steps: - - checkout - - restore_cache: - keys: - - v4-spm-deps-{{ checksum "Package.swift" }} - - run: - name: Copy Package file - command: cp Package.swift res - - run: - name: Build and Run Tests - no_output_timeout: 1800 - command: | - swift test -Xswiftc -DNOJSON - - run: - name: Restoring Package file - command: mv res Package.swift - - save_cache: - key: v2-spm-deps-{{ checksum "Package.swift" }} - paths: - - .build -workflows: - version: 2 - build-and-test: - jobs: - - MacOS - - Linux -experimental: - notify: - branches: - only: - - master - - develop diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..ac5dd8c --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,37 @@ +name: test +on: + pull_request: + push: + branches: + - master +jobs: + macos: + runs-on: macos-latest + env: + DEVELOPER_DIR: /Applications/Xcode_12.app/Contents/Developer + steps: + - uses: actions/checkout@v2 + - run: brew install openssl + - run: brew install libressl + - run: xcrun swift test --enable-test-discovery --sanitize=thread -Xcxx "-I/usr/local/opt/openssl/include" -Xlinker "-L/usr/local/opt/openssl/lib" + linux-4_2: + runs-on: ubuntu-latest + container: + image: swift:4.2 + steps: + - uses: actions/checkout@v2 + - run: apt-get -qq update && apt-get install -y libssl-dev + - run: swift test + linux: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + image: + - swift:5.2-focal + - swift:5.3-focal + container: ${{ matrix.image }} + steps: + - uses: actions/checkout@v2 + - run: apt-get -qq update && apt-get install -y libssl-dev + - run: swift test --enable-test-discovery --sanitize=thread diff --git a/Sources/JWTKeychain/Extensions/Router.swift b/Sources/JWTKeychain/Extensions/Router.swift index 4e739c4..5ebeb44 100644 --- a/Sources/JWTKeychain/Extensions/Router.swift +++ b/Sources/JWTKeychain/Extensions/Router.swift @@ -6,30 +6,31 @@ public extension Router { on container: Container ) throws { let config: JWTKeychainConfig = try container.make() + let controller = config.controller let middlewares: JWTKeychainMiddlewares = try container.make() let access = self.grouped(middlewares.accessMiddlewares) if let registerPath = config.endpoints.register { - self.post(registerPath, use: config.controller.register) + self.post(registerPath) { req in try controller.register(req: req) } } if let loginPath = config.endpoints.login { - self.post(loginPath, use: config.controller.logIn) + self.post(loginPath) { req in try controller.logIn(req: req) } } if let mePath = config.endpoints.me { - access.get(mePath, use: config.controller.me) + access.get(mePath) { req in try controller.me(req: req) } } if let updatePath = config.endpoints.update { - access.patch(updatePath, use: config.controller.update) + access.patch(updatePath) { req in try controller.update(req: req) } } if let refreshMiddlewares = middlewares.refreshMiddlewares, let tokenPath = config.endpoints.token { - self.grouped(refreshMiddlewares).post(tokenPath, use: config.controller.token) + self.grouped(refreshMiddlewares).post(tokenPath) { req in try config.controller.token(req: req) } } } }