diff --git a/api/util/http.ts b/api/util/http.ts index 8227ca9..516c94b 100644 --- a/api/util/http.ts +++ b/api/util/http.ts @@ -1,4 +1,4 @@ -import nodeFetch from 'isomorphic-unfetch' +import nodeFetch from 'isomorphic-unfetch'; export type HttpMethod = | 'GET' @@ -8,28 +8,28 @@ export type HttpMethod = | 'HEAD' | 'PATCH' | 'CONNECT' - | 'TRACE' + | 'TRACE'; -export interface NowRequest { - query: T +export interface NowRequest { + query: T; } export interface NowResponse { - setHeader: (label: string, body: string) => void - json: (obj: object) => void - status: (code: number) => NowResponse - length: number + setHeader: (label: string, body: string) => void; + json: (obj: object) => void; + status: (code: number) => NowResponse; + length: number; } export function fetch(url: string, method: HttpMethod = 'HEAD') { - return nodeFetch(url, { method: method }) + return nodeFetch(url, {method: method}); } export function send(res: NowResponse, data: object) { - res.setHeader('Cache-Control', 'maxage=0, s-maxage=43200') - res.json(data) + res.setHeader('Cache-Control', 's-maxage=86400'); + res.json(data); } export function sendError(res: NowResponse, error: Error) { - res.status(400).json({ error: error.message }) + res.status(400).json({error: error.message}); } diff --git a/now.json b/now.json index 4562b14..2d407d7 100644 --- a/now.json +++ b/now.json @@ -6,11 +6,11 @@ { "src": "/web/package.json", "use": "@now/static-build", - "config": { "distDir": "build" } + "config": {"distDir": "build"} }, { "src": "/api/services/*.ts", - "use": "@now/node@canary" + "use": "@now/node" } ], "routes": [ @@ -20,7 +20,8 @@ }, { "src": "/(.*)", - "dest": "/web/$1" + "dest": "/web/$1", + "headers": {"cache-control": "s-maxage=86400"} } ], "env": {