Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commited192b9

Browse files
committed
Playground API - retrieveSample
1 parent533da0c commited192b9

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

‎playground-api/handler.ts‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,45 @@ async function retrieveResult(request: HttpRequest): Promise<HttpResponse> {
294294
}
295295
}
296296

297+
asyncfunctionretrieveSample(request:HttpRequest):Promise<HttpResponse>{
298+
try{
299+
constid=request.queryStringParameters.id;
300+
constobject=awaits3.getObject({
301+
Bucket:'phpstan-playground',
302+
Key:'api/results/'+id+'.json',
303+
}).promise();
304+
constjson=JSON.parse(object.Bodyasstring);
305+
conststrictRules=typeofjson.config.strictRules!=='undefined' ?json.config.strictRules :false;
306+
constbleedingEdge=typeofjson.config.bleedingEdge!=='undefined' ?json.config.bleedingEdge :false;
307+
consttreatPhpDocTypesAsCertain=typeofjson.config.treatPhpDocTypesAsCertain!=='undefined' ?json.config.treatPhpDocTypesAsCertain :true;
308+
309+
constbodyJson:any={
310+
code:json.code,
311+
errors:json.errors,
312+
version:json.version,
313+
level:json.level,
314+
config:{
315+
strictRules,
316+
bleedingEdge,
317+
treatPhpDocTypesAsCertain,
318+
},
319+
};
320+
if(typeofjson.versionedErrors!=='undefined'){
321+
bodyJson.versionedErrors=json.versionedErrors;
322+
}else{
323+
bodyJson.versionedErrors=[{errors:json.errors,title:'PHP 7.4'}];
324+
}
325+
returnPromise.resolve({
326+
statusCode:200,
327+
body:JSON.stringify(bodyJson),
328+
});
329+
}catch(e){
330+
console.error(e);
331+
captureException(e);
332+
returnPromise.resolve({statusCode:500});
333+
}
334+
}
335+
297336
asyncfunctionretrieveLegacyResult(request:HttpRequest):Promise<HttpResponse>{
298337
try{
299338
constid=request.queryStringParameters.id;
@@ -343,5 +382,6 @@ const corsMiddleware = cors();
343382
module.exports={
344383
analyseResult:middy(analyseResult).use(corsMiddleware),
345384
retrieveResult:middy(retrieveResult).use(corsMiddleware),
385+
retrieveSample:middy(retrieveSample).use(corsMiddleware),
346386
retrieveLegacyResult:middy(retrieveLegacyResult).use(corsMiddleware),
347387
};

‎playground-api/serverless.yml‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,15 @@ functions:
2929
path:/result
3030
cors:true
3131

32+
retrieveSample:
33+
handler:handler.retrieveSample
34+
role:arn:aws:iam::928192134594:role/lambda-phpstan-playground
35+
events:
36+
-http:
37+
method:get
38+
path:/sample
39+
cors:true
40+
3241
retrieveLegacyResult:
3342
handler:handler.retrieveLegacyResult
3443
role:arn:aws:iam::928192134594:role/lambda-phpstan-playground

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp