Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
views['post.html'] = function (callback, path) {
var postID = path.replace(/^\/post\//, '');
database.view('posts', 'byPostID?key="' + postID + '"', function (response, error) {
if (error) console.log('Error.', error);
callback(response.rows[0].value);
});
};
views['meta.html'] = function (callback) {
database.read('meta', function (response, error) {
if (error) console.log('Error while getting view "' + func + '" of design document "posts".', error);
callback(response);
});
};
return views;
};
message: 'The error <code>' + error.code + ' ' + error.message + '</code> occured while loading the post.'
});
else if (!response.rows.length) callback(null, {
title: 'Not Found',
heading: 'Post not found',
message: "The post you were looking for wasn't found."
});
else callback(response.rows[0].value);
});
}
};
views['meta.html'] = {
load: function (callback) {
database.read('meta', function (response, error) {
if (error) callback(null, {
title: error.message,
heading: 'HTTP Error',
message: 'The error <code>' + error.code + ' ' + error.message + '</code> occured while loading meta.'
});
else callback(response);
});
}