Created
January 18, 2020 22:03
-
-
Save hendrixroa/f6f80dce7592e9a0c97b8713256cda86 to your computer and use it in GitHub Desktop.
Script to put rest api in format swagger to AWS APIGATEWAY
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import AWS = require('aws-sdk'); | |
import fs = require('fs'); | |
import minimist = require('minimist'); | |
const args: any = minimist(process.argv); | |
const apigateway = new AWS.APIGateway({ | |
region: process.env.AWS_DEFAULT_REGION || 'us-east-2', | |
}); | |
export class PutRestApi { | |
public async updateRestApi() { | |
process.chdir('..'); | |
const params: any = { | |
body: fs.readFileSync(`./src/apps/api/.swagger/${args.spec}`), | |
failOnWarnings: false, | |
mode: 'overwrite', | |
parameters: { | |
endpointConfigurationTypes: args.type, | |
}, | |
restApiId: args.api, | |
}; | |
return await apigateway.putRestApi(params).promise(); | |
} | |
} | |
const restApi: PutRestApi = new PutRestApi(); | |
restApi | |
.updateRestApi() | |
.then((data: any) => { | |
// tslint:disable-next-line: no-console | |
console.log('Update api rest: ', data); | |
}) | |
.catch((err: any) => { | |
// tslint:disable-next-line: no-console | |
console.error('error updating api rest: ', err); | |
process.exit(1); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment