File tree Expand file tree Collapse file tree 3 files changed +36
-8
lines changed
Expand file tree Collapse file tree 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) => {
2020 } )
2121 . then ( ( r ) => r . json ( ) )
2222 . then ( ( r ) => {
23- const latest = r [ 'dist-tags' ] . latest ;
24- const selected = req . query . version || latest ;
23+ const selected = req . query . version ;
2524 if ( ! r . versions [ selected ] ) {
2625 return res . status ( 404 ) . end ( 'no such version' ) ;
2726 }
@@ -30,12 +29,8 @@ module.exports = (req, res) => {
3029 redirect : 'manual' ,
3130 headers : { authorization } ,
3231 } ) . 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 ) ;
3934 } ) ;
4035 } ) ;
4136} ;
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 1515 "src" : " /download" ,
1616 "dest" : " /api/download.js"
1717 },
18+ {
19+ "src" : " /latest-version" ,
20+ "dest" : " /api/latest_version.js"
21+ },
1822 {
1923 "src" : " /.*" ,
2024 "status" : 404 ,
You can’t perform that action at this time.
0 commit comments