Skip to content

Commit

Permalink
feat: log how long it took to process the function
Browse files Browse the repository at this point in the history
  • Loading branch information
sznowicki committed Dec 22, 2023
1 parent 19b955e commit ae71af2
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions functions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {emitPageView} from '../lib/plausible.js';
import {parseQuery} from '../lib/parseQuery.js';

export const onRequestGet = async (context) => {
const timestamp = Date.now();
const { request, env } = context;
const { searchParams } = new URL(request.url);
const { q} = Object.fromEntries(searchParams.entries());
Expand Down Expand Up @@ -82,6 +83,9 @@ export const onRequestGet = async (context) => {
};

const html = Mustache.render(template, view);

console.log(`Processing took ${Date.now() - timestamp}ms`);

return new Response(html, {
headers: {
'content-type': 'text/html',
Expand Down

0 comments on commit ae71af2

Please sign in to comment.