File tree Expand file tree Collapse file tree 4 files changed +16
-5
lines changed
Expand file tree Collapse file tree 4 files changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -34,12 +34,17 @@ module.exports = (req, res) => {
3434 if ( req . headers . origin !== 'https://engine262.js.org' ) {
3535 return res . status ( 403 ) . send ( '403' ) ;
3636 }
37+ if ( req . method === 'OPTIONS' ) {
38+ res . writeHead ( 200 , { 'Allow' : 'OPTIONS, POST' } ) ;
39+ res . end ( ) ;
40+ return res ;
41+ }
3742 if ( req . method !== 'POST' ) {
3843 return res . status ( 405 ) . send ( '405' ) ;
3944 }
4045 if ( ! req . body || ! req . body . content || ! req . body . state ) {
4146 return res . status ( 400 ) . send ( '400' ) ;
4247 }
4348 return createGist ( req . body . content , req . body . state )
44- . then ( ( body ) => res . status ( 200 ) . json ( body ) ) ;
49+ . then ( ( body ) => res . status ( 200 ) . end ( body . id ) ) ;
4550} ;
Original file line number Diff line number Diff line change 88 "headers" : {
99 "Access-Control-Allow-Origin" : " https://engine262.js.org" ,
1010 "Access-Control-Allow-Headers" : " content-type" ,
11- "Access-Control-Allow-Methods" : " POST"
11+ "Access-Control-Allow-Methods" : " OPTIONS, POST"
1212 }
1313 },
1414 {
Original file line number Diff line number Diff line change 22 "name" : " server" ,
33 "dependencies" : {
44 "node-fetch" : " ^2.6.0"
5+ },
6+ "devDependencies" : {
7+ "babel-eslint" : " ^10.0.3" ,
8+ "eslint" : " ^6.1.0" ,
9+ "eslint-config-airbnb-base" : " ^14.0.0" ,
10+ "eslint-plugin-import" : " ^2.18.2"
511 }
612}
Original file line number Diff line number Diff line change @@ -91,7 +91,7 @@ export function setState(name, value) {
9191document . querySelector ( '#save-to-gist' )
9292 . addEventListener ( 'click' , async ( ) => {
9393 const s = await state ;
94- const body = await fetch ( 'https://engine262-api.snek.now.sh/api/gist' , {
94+ const id = await fetch ( 'https://engine262-api.snek.now.sh/api/gist' , {
9595 method : 'POST' ,
9696 headers : {
9797 'Content-Type' : 'application/json' ,
@@ -104,8 +104,8 @@ document.querySelector('#save-to-gist')
104104 } ,
105105 } ) ,
106106
107- } ) . then ( ( r ) => r . json ( ) ) ;
107+ } ) . then ( ( r ) => r . text ( ) ) ;
108108 isGist = true ;
109- s . set ( 'gist' , body . id ) ;
109+ s . set ( 'gist' , id ) ;
110110 await updateState ( ) ;
111111 } ) ;
You can’t perform that action at this time.
0 commit comments