Files
vercel/api/examples/list.ts
Andy cfb84b5328 [api] Fix filename and update .vercelignore and vercel.json (#4511)
- Fix a filename in the examples API
- Rename .nowignore to .vercelignore
- Rename now.json to vercel.json
2020-05-27 17:19:15 -04:00

28 lines
850 B
TypeScript

import { extract } from '../_lib/examples/extract';
import { summary } from '../_lib/examples/summary';
import { NowRequest, NowResponse } from '@now/node';
import { mapOldToNew } from '../_lib/examples/map-old-to-new';
import { withApiHandler } from '../_lib/util/with-api-handler';
export default withApiHandler(async function(
req: NowRequest,
res: NowResponse
) {
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]);
});