-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: goodbye scraping, hello static data
- Loading branch information
Showing
22 changed files
with
335 additions
and
693 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
dist | ||
node_modules | ||
.vercel | ||
.yarn | ||
.vscode | ||
|
||
*.log |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
data/ |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { KeywordOptions } from '../../types' | ||
import { createSpecResponse } from '../helpers/spec' | ||
import type { FastifyInstance, FastifyReply, FastifyRequest } from 'fastify' | ||
|
||
export const search = (app: FastifyInstance) => { | ||
return async (request: FastifyRequest<{ Querystring: KeywordOptions }>, reply: FastifyReply) => { | ||
const { q } = request.query | ||
// TODO: search by province, regency, or district | ||
const data = app.fuse.search(q).sort((a, b) => (a.score || 0) - (b.score || 0)) | ||
|
||
reply.header('Cache-Control', 's-maxage=86400, stale-while-revalidate=604800') | ||
|
||
const result = data.map(({ item }) => item) | ||
const response = createSpecResponse(result) | ||
|
||
return reply.send(response) | ||
} | ||
} |
File renamed without changes.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.