diff --git a/bun.lockb b/bun.lockb index 55be093..8bd91d7 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/docker-compose.yml b/docker-compose.yml index b4755c3..2eb0720 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,3 @@ -version: "3" - services: mongodb: image: "mongo:latest" diff --git a/package.json b/package.json index e4e6870..b1389e8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bun-api-starter", - "version": "1.2.0", + "version": "1.3.0", "scripts": { "test": "NODE_ENV=test bun test ./test/**.test.ts", "dev": "bun run --watch src/app.ts", @@ -10,27 +10,29 @@ "lint:fix": "eslint src test --fix" }, "dependencies": { - "@elysiajs/cors": "^1.0.2", - "@elysiajs/jwt": "^1.0.2", - "@elysiajs/swagger": "^1.0.4", - "elysia": "^1.0.14", + "@elysiajs/cors": "^1.1.0", + "@elysiajs/jwt": "^1.1.0", + "@elysiajs/swagger": "^1.1.1", + "elysia": "^1.1.8", "http-status-codes": "^2.3.0", - "mongoose": "^8.3.2", - "yoctocolors": "^2.0.0" + "mongoose": "^8.5.4", + "yoctocolors": "^2.1.1" }, "devDependencies": { - "@typescript-eslint/eslint-plugin": "^7.7.1", - "@typescript-eslint/parser": "^7.7.1", - "bun-types": "^1.1.4", - "eslint": "^8.57.0", + "@eslint/eslintrc": "^3.1.0", + "@eslint/js": "^9.9.1", + "@typescript-eslint/eslint-plugin": "^8.3.0", + "@typescript-eslint/parser": "^8.3.0", + "bun-types": "^1.1.26", + "eslint": "^9.9.1", "eslint-config-prettier": "^9.1.0", - "eslint-plugin-jsdoc": "^48.2.3", - "eslint-plugin-prettier": "^5.1.3", - "eslint-plugin-simple-import-sort": "^12.1.0", - "eslint-plugin-sonarjs": "^0.25.1", - "husky": "^9.0.11", - "lint-staged": "^15.2.2", - "prettier": "^3.2.5" + "eslint-plugin-jsdoc": "^50.2.2", + "eslint-plugin-prettier": "^5.2.1", + "eslint-plugin-simple-import-sort": "^12.1.1", + "eslint-plugin-sonarjs": "^2.0.1", + "husky": "^9.1.5", + "lint-staged": "^15.2.9", + "prettier": "^3.3.3" }, "lint-staged": { "*.{js,ts}": [ diff --git a/src/app.ts b/src/app.ts index 517e852..419c060 100644 --- a/src/app.ts +++ b/src/app.ts @@ -15,8 +15,6 @@ db.connect(); app .use(loggerPlugin) - .use(securityPlugin) - .use(errorPlugin) .use( swagger({ path: '/docs', @@ -28,6 +26,8 @@ app } }) ) + .use(securityPlugin) + .use(errorPlugin) .get('/', () => ({ name: config.app.name, version: config.app.version diff --git a/src/plugins/authenticate.ts b/src/plugins/authenticate.ts index 9ae744d..f70c9a2 100644 --- a/src/plugins/authenticate.ts +++ b/src/plugins/authenticate.ts @@ -4,8 +4,13 @@ import UnauthorizedError from '../domain/exceptions/UnauthorizedError'; export default (app: Elysia) => // @ts-expect-error This remains valid after JWT is implemented. - app.derive(async ({ jwt, headers: { authorization } }) => { - const user = await jwt.verify(authorization?.split(' ')[1]); + app.derive(async ({ jwt, headers, request }) => { + // TODO: Fix me later. + if (request.url.includes('/docs')) { + return; + } + + const user = await jwt.verify(headers.authorization?.split(' ')[1]); if (!user) { throw new UnauthorizedError('Invalid token!');