-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.ts
More file actions
27 lines (22 loc) · 783 Bytes
/
server.ts
File metadata and controls
27 lines (22 loc) · 783 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import 'dotenv/config'
import { Hono } from 'hono'
import { serve, getRequestListener } from '@hono/node-server'
import connectDB from './config/db.js'
import usersRouter from './routes/api/users.js'
import authRouter from './routes/api/auth.js'
import profileRouter from './routes/api/profile.js'
import postsRouter from './routes/api/posts.js'
connectDB()
const app = new Hono()
app.route('/api/users', usersRouter)
app.route('/api/auth', authRouter)
app.route('/api/profile', profileRouter)
app.route('/api/posts', postsRouter)
// local dev server
if (!process.env.VERCEL) {
const PORT = Number(process.env.PORT ?? 5001)
serve({ fetch: app.fetch, port: PORT }, () => {
console.log(`Server started on port ${PORT}`)
})
}
export default getRequestListener(app.fetch)