Files
vercel/api/examples/list.ts
Steven f5f07c5d15 [all] Remove more "now" references (#5944)
Follow up to #5928 to remove a few more "now" references and replace with "vercel" where appropriate.
2021-03-08 10:08:09 -05:00

28 lines
866 B
TypeScript

import { extract } from '../_lib/examples/extract';
import { summary } from '../_lib/examples/summary';
import { VercelRequest, VercelResponse } from '@vercel/node';
import { mapOldToNew } from '../_lib/examples/map-old-to-new';
import { withApiHandler } from '../_lib/util/with-api-handler';
export default withApiHandler(async function (
req: VercelRequest,
res: VercelResponse
) {
await extract('https://github.com/vercel/vercel/archive/master.zip', '/tmp');
const exampleList = summary('/tmp/vercel-master/examples');
const existingExamples = Array.from(exampleList).map(key => ({
name: key,
visible: true,
suggestions: [],
}));
const oldExamples = Object.keys(mapOldToNew).map(key => ({
name: key,
visible: false,
suggestions: mapOldToNew[key],
}));
res.status(200).json([...existingExamples, ...oldExamples]);
});