Skip to content

CORS & friends #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 23, 2024
Merged
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
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)
})