forked from vercel/vercel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathframeworks.ts
40 lines (36 loc) · 1.1 KB
/
frameworks.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import { NowRequest, NowResponse } from '@vercel/node';
import { withApiHandler } from './_lib/util/with-api-handler';
import _frameworks, { Framework } from '../packages/frameworks';
const frameworks = (_frameworks as Framework[])
.sort(
(a, b) =>
(a.sort || Number.MAX_SAFE_INTEGER) - (b.sort || Number.MAX_SAFE_INTEGER)
)
.map(frameworkItem => {
const framework = {
...frameworkItem,
detectors: undefined,
sort: undefined,
dependency: undefined,
defaultRoutes: undefined,
cachePattern: undefined,
devCommand: undefined,
buildCommand: undefined,
};
if (framework.logo) {
framework.logo = `https://res.cloudinary.com/zeit-inc/image/fetch/${framework.logo}`;
}
return framework;
});
export default withApiHandler(async function (
req: NowRequest,
res: NowResponse
) {
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Allow-Methods', 'GET');
res.setHeader(
'Access-Control-Allow-Headers',
'Authorization, Accept, Content-Type'
);
return res.status(200).json(frameworks);
});