Better async error handling

This commit is contained in:
Michael Jackson
2019-07-30 17:06:27 -07:00
parent 7582c641fb
commit 7f90203a66
9 changed files with 102 additions and 46 deletions

View File

@ -2,9 +2,10 @@ import { renderToString, renderToStaticMarkup } from 'react-dom/server';
import BrowseApp from '../client/browse/App.js';
import MainTemplate from '../templates/MainTemplate.js';
import { getAvailableVersions } from '../utils/npm.js';
import asyncHandler from '../utils/asyncHandler.js';
import getScripts from '../utils/getScripts.js';
import { createElement, createHTML } from '../utils/markup.js';
import { getAvailableVersions } from '../utils/npm.js';
const doctype = '<!DOCTYPE html>';
const globalURLs =
@ -20,7 +21,7 @@ const globalURLs =
'react-dom': '/react-dom@16.8.6/umd/react-dom.development.js'
};
export default async function serveBrowsePage(req, res) {
async function serveBrowsePage(req, res) {
const availableVersions = await getAvailableVersions(req.packageName);
const data = {
packageName: req.packageName,
@ -51,3 +52,5 @@ export default async function serveBrowsePage(req, res) {
})
.send(html);
}
export default asyncHandler(serveBrowsePage);