mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-18 13:35:08 +00:00
19 lines
381 B
JavaScript
19 lines
381 B
JavaScript
import posts from './_posts.js';
|
|
|
|
export function get(req, res) {
|
|
const post = posts.find(post => post.slug === req.params.slug);
|
|
|
|
if (post) {
|
|
res.writeHead(200, {
|
|
'Content-Type': 'application/json'
|
|
});
|
|
|
|
res.end(JSON.stringify(post));
|
|
} else {
|
|
res.writeHead(404, {
|
|
'Content-Type': 'application/json'
|
|
});
|
|
|
|
res.end(JSON.stringify({ message: 'not found' }));
|
|
}
|
|
} |