Skip to content

Commit

Permalink
Update API deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
diegocouto committed Jan 27, 2022
1 parent ddf51f6 commit d5edb27
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 3 deletions.
7 changes: 7 additions & 0 deletions .vercel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"functions": {
"api/search.ts": {
"includeFiles": "cache/**"
}
}
}
File renamed without changes.
2 changes: 1 addition & 1 deletion pages/api/search.ts → api/search.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { NextApiRequest, NextApiResponse } from 'next';

import Search from '../../utils/libs/search';
import Search from '../utils/libs/search';

export default (req: NextApiRequest, res: NextApiResponse) => {
const term = req.query.term as string;
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions utils/libs/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import path from 'path';

import { getArticle, getArticlesList } from '../datasource';

const CACHE_PATH = 'public';
const CACHE_PATH = 'cache';
const CACHE_FILE = 'data.json';

export interface CacheEntry {
Expand Down Expand Up @@ -35,7 +35,7 @@ export function updateArticlesCache() {
}

export function getArticlesCache(): CacheEntry[] {
const rawData = fs.readFileSync(path.join(CACHE_PATH, CACHE_FILE));
const rawData = fs.readFileSync(path.join(CACHE_PATH, CACHE_FILE), 'utf8');

if (!rawData) {
return [];
Expand Down

0 comments on commit d5edb27

Please sign in to comment.