Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ DATABASE_URL=
PORT=
API_PREFIX=
NODE_ENV=
RP_ID=
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
MICROSOFT_CLIENT_ID=
Expand Down
10 changes: 0 additions & 10 deletions .swcrc

This file was deleted.

4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

Welcome to the Task Pro App Backend, the powerhouse behind the ultimate tool for managing your tasks efficiently. This backend repository handles all the server-side logic, data management, and API integrations needed to support Task Pro's seamless performance.

_Link to the swagger docs:_ https://api.taskpro.qzz.io/docs

_Link to the frontend repo:_ https://github.com/chertik77/TaskPro-frontend

## Features
Expand Down Expand Up @@ -46,4 +44,4 @@ _Link to the frontend repo:_ https://github.com/chertik77/TaskPro-frontend

## Languages and Tools

![Languages and Tools](https://skills.syvixor.com/api/icons?i=nodejs,ts,expressjs,prisma,mongodb,swagger,cloudinary,redis,zod,betterauth,resend,githubactions,yarn,commitlint,eslint,prettier,postman,vscode&perline=9)
![Languages and Tools](https://skills.syvixor.com/api/icons?i=nodejs,ts,hono,prisma,mongodb,swagger,cloudinary,redis,zod,betterauth,resend,githubactions,yarn,commitlint,eslint,prettier,postman,vscode&perline=9)
49 changes: 31 additions & 18 deletions app/app.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,43 @@
import express from 'express'
import { toNodeHandler } from 'better-auth/node'
import cookieParser from 'cookie-parser'
import cors from 'cors'
import helmet from 'helmet'
import logger from 'morgan'
import * as z from 'zod'
import type { AuthVariables } from './types'

import { Hono } from 'hono'
import { cors } from 'hono/cors'
import { HTTPException } from 'hono/http-exception'
import { logger } from 'hono/logger'
import { secureHeaders } from 'hono/secure-headers'
import z from 'zod'

import { env, zodConfig } from './config'
import { auth } from './lib'
import { globalErrorHandler, notFoundHandler } from './middlewares'
import { apiRouter } from './routes'

export const app = express()
export const app = new Hono<{ Variables: AuthVariables }>()

z.config(zodConfig)

app.use(cors({ origin: env.ALLOWED_ORIGINS, credentials: true }))
app.use('*', logger())
app.use('*', secureHeaders())

app.use('*', cors({ origin: env.ALLOWED_ORIGINS, credentials: true }))

app.on(['GET', 'POST'], `${env.API_PREFIX}/auth/*`, c =>
auth.handler(c.req.raw)
)

app.route(env.API_PREFIX, apiRouter)

app.all(`${env.API_PREFIX}/auth/*splat`, toNodeHandler(auth))
app.notFound(c => c.json({ status: 404, message: 'Not found' }, 404))

app.use(helmet())
app.use(logger(app.get('env') === 'development' ? 'dev' : 'combined'))
app.use(cookieParser())
app.use(express.json())
app.onError((err, c) => {
if (err instanceof HTTPException) return err.getResponse()

app.use(env.API_PREFIX, apiRouter)
console.error(err)

app.use(notFoundHandler)
app.use(globalErrorHandler)
return c.json(
{
status: err instanceof HTTPException ? err.status : 500,
message: err.message || 'Server error'
},
err instanceof HTTPException ? err.status : 500
)
})
5 changes: 4 additions & 1 deletion app/config/env.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import 'dotenv/config'
import { loadEnvFile } from 'node:process'

import * as z from 'zod'

loadEnvFile(process.cwd() + '/.env')

const envSchema = z.object({
CLOUDINARY_API_KEY: z.string(),
CLOUDINARY_API_SECRET: z.string(),
Expand All @@ -19,6 +21,7 @@ const envSchema = z.object({
REDIS_PORT: z.coerce.number().int().positive().min(1000).max(65535),
PORT: z.coerce.number().int().positive().min(1000).max(65535),
API_PREFIX: z.string().default(''),
RP_ID: z.hostname(),
NODE_ENV: z.enum(['development', 'production']).default('development'),
ALLOWED_ORIGINS: z
.string()
Expand Down
2 changes: 1 addition & 1 deletion app/config/redis.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Redis from 'ioredis'
import { Redis } from 'ioredis'

import { env } from './env.config'

Expand Down
141 changes: 0 additions & 141 deletions app/controllers/board.controller.ts

This file was deleted.

Loading
Loading