Files
sapper/test/app/routes/blog.json.js
2018-03-10 09:39:07 -05:00

17 lines
339 B
JavaScript

import posts from './blog/_posts.js';
const contents = JSON.stringify(posts.map(post => {
return {
title: post.title,
slug: post.slug
};
}));
export function get(req, res) {
res.writeHead(200, {
'Content-Type': 'application/json',
'Cache-Control': `max-age=${30 * 60 * 1e3}` // cache for 30 minutes
});
res.end(contents);
}