diff --git a/commitlint.config.js b/commitlint.config.js index 3f5e287..7c4ff4d 100644 --- a/commitlint.config.js +++ b/commitlint.config.js @@ -1 +1 @@ -export default { extends: ['@commitlint/config-conventional'] }; +export default { extends: ['@commitlint/config-conventional'] } diff --git a/eslint.config.js b/eslint.config.js index 1a0cafe..5f5d47c 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -1,7 +1,7 @@ -import globals from 'globals'; -import pluginJs from '@eslint/js'; -import tseslint from 'typescript-eslint'; -import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended'; +import globals from 'globals' +import pluginJs from '@eslint/js' +import tseslint from 'typescript-eslint' +import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended' export default [ { files: ['**/*.{js,mjs,cjs,ts}'] }, { @@ -15,4 +15,4 @@ export default [ pluginJs.configs.recommended, ...tseslint.configs.recommended, eslintPluginPrettierRecommended -]; +] diff --git a/prettier.config.js b/prettier.config.js index b8dafc9..3bcd3b5 100644 --- a/prettier.config.js +++ b/prettier.config.js @@ -1,7 +1,7 @@ export default { - semi: true, + semi: false, trailingComma: 'none', singleQuote: true, printWidth: 120, tabWidth: 2 -}; +} diff --git a/src/app.ts b/src/app.ts index 07f891a..716e88a 100644 --- a/src/app.ts +++ b/src/app.ts @@ -1,40 +1,40 @@ -import { OpenAPIHono } from '@hono/zod-openapi'; -import { apiReference } from '@scalar/hono-api-reference'; -import { logger } from 'hono/logger'; -import { prettyJSON } from 'hono/pretty-json'; -import { Home } from './pages/home'; -import { Routes } from '#common/types'; -import type { HTTPException } from 'hono/http-exception'; +import { OpenAPIHono } from '@hono/zod-openapi' +import { apiReference } from '@scalar/hono-api-reference' +import { logger } from 'hono/logger' +import { prettyJSON } from 'hono/pretty-json' +import { Home } from './pages/home' +import { Routes } from '#common/types' +import type { HTTPException } from 'hono/http-exception' export class App { - private app: OpenAPIHono; + private app: OpenAPIHono constructor(routes: Routes[]) { - this.app = new OpenAPIHono(); - this.initializeGlobalMiddleware(); - this.initializeRoutes(routes); - this.initializeSwaggerUI(); - this.initializeRouteFallback(); - this.initializeErrorHandler(); + this.app = new OpenAPIHono() + this.initializeGlobalMiddleware() + this.initializeRoutes(routes) + this.initializeSwaggerUI() + this.initializeRouteFallback() + this.initializeErrorHandler() } private initializeRoutes(routes: Routes[]) { routes.forEach((route) => { - route.initRoutes(); - this.app.route('/api', route.controller); - }); - this.app.route('/', Home); + route.initRoutes() + this.app.route('/api', route.controller) + }) + this.app.route('/', Home) } private initializeGlobalMiddleware() { - this.app.use(logger()); - this.app.use(prettyJSON()); + this.app.use(logger()) + this.app.use(prettyJSON()) } private initializeSwaggerUI() { this.app.doc31('/swagger', (c) => { - const { protocol: urlProtocol, hostname, port } = new URL(c.req.url); - const protocol = c.req.header('x-forwarded-proto') ? `${c.req.header('x-forwarded-proto')}:` : urlProtocol; + const { protocol: urlProtocol, hostname, port } = new URL(c.req.url) + const protocol = c.req.header('x-forwarded-proto') ? `${c.req.header('x-forwarded-proto')}:` : urlProtocol return { openapi: '3.1.0', @@ -52,8 +52,8 @@ export class App { description: 'Current environment' } ] - }; - }); + } + }) this.app.get( '/docs', @@ -76,7 +76,7 @@ export class App { url: '/swagger' } }) - ); + ) } private initializeRouteFallback() { @@ -87,16 +87,16 @@ export class App { message: 'oops route not found!!. check docs at https://exercisedb-api.vercel.app/docs' }, 404 - ); - }); + ) + }) } private initializeErrorHandler() { this.app.onError((err, c) => { - const error = err as HTTPException; - return c.json({ success: false, message: error.message }, error.status || 500); - }); + const error = err as HTTPException + return c.json({ success: false, message: error.message }, error.status || 500) + }) } public getApp() { - return this.app; + return this.app } } diff --git a/src/common/types/index.ts b/src/common/types/index.ts index 7444ff3..954f8fc 100644 --- a/src/common/types/index.ts +++ b/src/common/types/index.ts @@ -1 +1 @@ -export * from './route.type'; +export * from './route.type' diff --git a/src/common/types/route.type.ts b/src/common/types/route.type.ts index 33d0fdb..0ca2990 100644 --- a/src/common/types/route.type.ts +++ b/src/common/types/route.type.ts @@ -1,6 +1,6 @@ -import type { OpenAPIHono } from '@hono/zod-openapi'; +import type { OpenAPIHono } from '@hono/zod-openapi' export interface Routes { - controller: OpenAPIHono; - initRoutes: () => void; + controller: OpenAPIHono + initRoutes: () => void } diff --git a/src/pages/home.tsx b/src/pages/home.tsx index 644141e..fc02907 100644 --- a/src/pages/home.tsx +++ b/src/pages/home.tsx @@ -1,12 +1,12 @@ -import { Hono } from 'hono'; +import { Hono } from 'hono' -export const Home = new Hono(); +export const Home = new Hono() export const Meteors = ({ number }: { number: number }) => { return ( <> {Array.from({ length: number || 30 }, (_, idx) => { - { animationDelay: `${Math.random() * (0.8 - 0.2) + 0.2}s`, animationDuration: `${Math.floor(Math.random() * (10 - 2) + 2)}s` }} - >; + > })} - ); -}; + ) +} Home.get('/', (c) => { - const title = 'ExerciseDB API'; + const title = 'ExerciseDB API' const description = - 'Access detailed data on over 1300+ exercises with the ExerciseDB API. This API offers extensive information on each exercise, including target body parts, equipment needed, GIFs for visual guidance, and step-by-step instructions.'; + 'Access detailed data on over 1300+ exercises with the ExerciseDB API. This API offers extensive information on each exercise, including target body parts, equipment needed, GIFs for visual guidance, and step-by-step instructions.' return c.html( @@ -172,5 +172,5 @@ Home.get('/', (c) => { - ); -}); + ) +}) diff --git a/src/server.ts b/src/server.ts index 9ca2774..5d47210 100644 --- a/src/server.ts +++ b/src/server.ts @@ -1,5 +1,5 @@ -import { App } from './app'; +import { App } from './app' -const app = new App([]).getApp(); +const app = new App([]).getApp() -export default app; +export default app diff --git a/vitest.config.ts b/vitest.config.ts index ca9eaaa..f71b245 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -1,4 +1,4 @@ -import { configDefaults, defineConfig } from 'vitest/config'; +import { configDefaults, defineConfig } from 'vitest/config' export default defineConfig({ test: { @@ -18,4 +18,4 @@ export default defineConfig({ } } } -}); +})