File tree 3 files changed +36
-8
lines changed
3 files changed +36
-8
lines changed Original file line number Diff line number Diff line change @@ -20,8 +20,7 @@ module.exports = (req, res) => {
20
20
} )
21
21
. then ( ( r ) => r . json ( ) )
22
22
. then ( ( r ) => {
23
- const latest = r [ 'dist-tags' ] . latest ;
24
- const selected = req . query . version || latest ;
23
+ const selected = req . query . version ;
25
24
if ( ! r . versions [ selected ] ) {
26
25
return res . status ( 404 ) . end ( 'no such version' ) ;
27
26
}
@@ -30,12 +29,8 @@ module.exports = (req, res) => {
30
29
redirect : 'manual' ,
31
30
headers : { authorization } ,
32
31
} ) . then ( ( r2 ) => {
33
- res . status ( 200 ) ;
34
- return res . json ( {
35
- latest,
36
- selected,
37
- tarball : r2 . headers . get ( 'location' ) ,
38
- } ) ;
32
+ res . writeHead ( r2 . status , r2 . headers . raw ( ) ) ;
33
+ r2 . body . pipe ( res ) ;
39
34
} ) ;
40
35
} ) ;
41
36
} ;
Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+
3
+ const fetch = require ( 'node-fetch' ) ;
4
+
5
+ const authorization = `Bearer ${ process . env . GH_TOKEN } ` ;
6
+
7
+ module . exports = ( req , res ) => {
8
+ if ( req . method === 'OPTIONS' ) {
9
+ res . writeHead ( 200 , { 'Allow' : 'OPTIONS, GET' } ) ;
10
+ res . end ( ) ;
11
+ return res ;
12
+ }
13
+ if ( req . method !== 'GET' ) {
14
+ return res . status ( 405 ) . send ( '405' ) ;
15
+ }
16
+
17
+ delete req . headers . host ;
18
+ return fetch ( 'https://npm.pkg.github.com/@engine262/engine262' , {
19
+ headers : { ...req . headers , authorization } ,
20
+ } )
21
+ . then ( ( r ) => r . json ( ) )
22
+ . then ( ( r ) => {
23
+ const latest = r [ 'dist-tags' ] . latest ;
24
+ res . status ( 200 ) ;
25
+ return res . json ( {
26
+ latest,
27
+ } ) ;
28
+ } ) ;
29
+ } ;
Original file line number Diff line number Diff line change 15
15
"src" : " /download" ,
16
16
"dest" : " /api/download.js"
17
17
},
18
+ {
19
+ "src" : " /latest-version" ,
20
+ "dest" : " /api/latest_version.js"
21
+ },
18
22
{
19
23
"src" : " /.*" ,
20
24
"status" : 404 ,
You can’t perform that action at this time.
0 commit comments