Skip to content

Commit

Permalink
Merge pull request #9 from vincent99/main
Browse files Browse the repository at this point in the history
CORS & friends
  • Loading branch information
vincent99 authored Apr 23, 2024
2 parents 06b2616 + 72382ad commit 0a0ef15
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 4 deletions.
29 changes: 29 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Nuxt dev/build outputs
.output
.data
.nuxt
.nitro
.cache
dist
tmp

# Node dependencies
node_modules

# Logs
logs
*.log

# Misc
.DS_Store
.fleet
.idea

# Local env files
.env
.env.*
!.env.example

# Go binaries
indexer/indexer
parser/parser
4 changes: 4 additions & 0 deletions nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ export default defineNuxtConfig({
'@nuxt/ui',
'@nuxtjs/tailwindcss',
],
routeRules: {
// Allow cross-origin requests for the API (GPTStudio needs this)
'/api/**': { cors: true },
},
runtimeConfig: {
public: {
// Anything in here is exposed to the client, do not put secrets in here
Expand Down
13 changes: 9 additions & 4 deletions src/server/api/search.get.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import * as db from '@/lib/db'

const pageSize = 10

export default defineEventHandler(async (event) => {
setResponseHeader(event, 'Content-Type', 'application/json')
const {q, page} = getQuery(event)
return await db.getToolsForQuery(q as string, page as number, pageSize)
let { q, page, limit } = getQuery(event)

limit = Number.parseInt(limit as string, 10)

if (!limit || Number.isNaN(limit)) {
limit = 10
}

return await db.getToolsForQuery(q as string, page as number, limit as number)
})

0 comments on commit 0a0ef15

Please sign in to comment.