import { createExpressMiddleware } from '@trpc/server/adapters/express'
import cookieParser from 'cookie-parser'
import express from 'express'
import { createContext } from './trpc/context'
import { appRouter } from './trpc/routers'

const app = express()
app.use(cookieParser())
app.use(express.json())

app.use(
  '/trpc',
  createExpressMiddleware({
    router: appRouter,
    createContext,
  }),
)

app.listen(process.env.PORT || 4000, () => {
  console.log('✅ Server running')
})
