Spaces:
Build error
Build error
feat: support explicit q passing in search
Browse files
backend/functions/src/cloud-functions/searcher.ts
CHANGED
|
@@ -86,11 +86,12 @@ export class SearcherHost extends RPCHost {
|
|
| 86 |
count: number,
|
| 87 |
crawlerOptions: CrawlerOptions,
|
| 88 |
braveSearchExplicitOperators: BraveSearchExplicitOperatorsDto,
|
|
|
|
| 89 |
) {
|
| 90 |
const uid = await auth.solveUID();
|
| 91 |
let chargeAmount = 0;
|
| 92 |
const noSlashPath = ctx.req.url.slice(1);
|
| 93 |
-
if (!noSlashPath) {
|
| 94 |
const latestUser = uid ? await auth.assertUser() : undefined;
|
| 95 |
if (!ctx.req.accepts('text/plain') && (ctx.req.accepts('text/json') || ctx.req.accepts('application/json'))) {
|
| 96 |
|
|
@@ -151,7 +152,7 @@ export class SearcherHost extends RPCHost {
|
|
| 151 |
delete crawlerOptions.html;
|
| 152 |
|
| 153 |
const crawlOpts = this.crawler.configure(crawlerOptions);
|
| 154 |
-
const searchQuery = braveSearchExplicitOperators.addTo(ctx.req.path.slice(1));
|
| 155 |
const r = await this.cachedWebSearch({
|
| 156 |
q: searchQuery,
|
| 157 |
count: Math.floor(count + 2)
|
|
|
|
| 86 |
count: number,
|
| 87 |
crawlerOptions: CrawlerOptions,
|
| 88 |
braveSearchExplicitOperators: BraveSearchExplicitOperatorsDto,
|
| 89 |
+
@Param('q') q?: string,
|
| 90 |
) {
|
| 91 |
const uid = await auth.solveUID();
|
| 92 |
let chargeAmount = 0;
|
| 93 |
const noSlashPath = ctx.req.url.slice(1);
|
| 94 |
+
if (!noSlashPath && !q) {
|
| 95 |
const latestUser = uid ? await auth.assertUser() : undefined;
|
| 96 |
if (!ctx.req.accepts('text/plain') && (ctx.req.accepts('text/json') || ctx.req.accepts('application/json'))) {
|
| 97 |
|
|
|
|
| 152 |
delete crawlerOptions.html;
|
| 153 |
|
| 154 |
const crawlOpts = this.crawler.configure(crawlerOptions);
|
| 155 |
+
const searchQuery = braveSearchExplicitOperators.addTo(q || ctx.req.path.slice(1));
|
| 156 |
const r = await this.cachedWebSearch({
|
| 157 |
q: searchQuery,
|
| 158 |
count: Math.floor(count + 2)
|