Skip to content

Commit 6c881b0

Browse files
authored
Merge pull request #759 from pharindoko/release/1.7
Release/1.7
2 parents 4ef9808 + d31b868 commit 6c881b0

File tree

16 files changed

+2138
-517
lines changed

16 files changed

+2138
-517
lines changed

packages/cli/package-lock.json

Lines changed: 1018 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/cli/package.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,16 @@
6363
],
6464
"homepage": "https://github.com/pharindoko/json-serverless",
6565
"keywords": [
66-
"oclif"
66+
"api",
67+
"graphql",
68+
"aws",
69+
"json",
70+
"rest",
71+
"serverless",
72+
"rest-api",
73+
"serverless-framework",
74+
"swagger-ui",
75+
"json-server"
6776
],
6877
"license": "MIT",
6978
"main": "lib/index.js",

packages/cli/src/actions/aws-actions.ts

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,11 @@
1-
process.env.AWS_SDK_LOAD_CONFIG = 'true';
21
import AWS = require('aws-sdk');
32

4-
const ec2: AWS.EC2 = new AWS.EC2();
3+
const ec2: AWS.EC2 = new AWS.EC2({ region: 'us-east-1' });
54
const cloudformation: AWS.CloudFormation = new AWS.CloudFormation();
65
const sts: AWS.STS = new AWS.STS();
7-
/* if (!AWS.config.region) {
8-
AWS.config.update({ region: 'us-east-1' });
9-
}
10-
*/
116

127
export class AWSActions {
138
constructor() {}
14-
static getCurrentRegion(): string {
15-
if (!AWS.config.region) {
16-
AWS.config.update({ region: 'us-east-1' });
17-
}
18-
return AWS.config.region!;
19-
}
209

2110
static async checkValidAWSIdentity(): Promise<
2211
AWS.STS.GetCallerIdentityResponse
@@ -32,15 +21,13 @@ export class AWSActions {
3221

3322
static async getAllRegionsByName(): Promise<Array<Object>> {
3423
try {
35-
let regions: Object[];
24+
let regions: string[] = [];
3625
const result = await ec2.describeRegions({ AllRegions: true }).promise();
3726

3827
regions = result
3928
.Regions!.sort((a, b) => a.RegionName!.localeCompare(b.RegionName!))
4029
.map((x) => {
41-
return new Object({
42-
name: x.RegionName,
43-
});
30+
return x.RegionName!;
4431
});
4532
return regions;
4633
} catch (error) {

packages/cli/src/commands/create-stack.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ export class CreateStackCommand extends Command {
139139
let region: string | undefined;
140140
if (flags.region) {
141141
region = flags.region;
142+
await this.verifyRegion(region);
142143
} else {
143144
region = await this.getRegion();
144145
}
@@ -312,6 +313,17 @@ export class CreateStackCommand extends Command {
312313
}
313314
}
314315

316+
private async verifyRegion(region: string | undefined) {
317+
let regions = await AWSActions.getAllRegionsByName();
318+
if (!regions.find((x) => x === region)) {
319+
this.error(
320+
'Please check the value for the region parameter - the region ' +
321+
region +
322+
' cannot be found in aws and is not valid'
323+
);
324+
}
325+
}
326+
315327
private async checkIdentity() {
316328
cli.action.start(
317329
`${chalk.blueBright('Check AWS Identity')}`,
@@ -364,8 +376,7 @@ export class CreateStackCommand extends Command {
364376

365377
private async getRegion() {
366378
let regions = await AWSActions.getAllRegionsByName();
367-
regions.unshift({ name: AWSActions.getCurrentRegion() });
368-
let region = '';
379+
let region = null;
369380

370381
let responses: any = await inquirer.prompt([
371382
{

packages/cli/src/commands/validate.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { JSONValidator, Output } from 'json-serverless-lib';
33
import { Helpers } from '../actions/helpers';
44
import chalk from 'chalk';
55
export class Validate extends Command {
6-
static description = 'describe the command here';
6+
static description = 'validate the json file against specific rules';
77

88
static flags = {
99
help: flags.help({ char: 'h' }),

packages/server/package-lock.json

Lines changed: 35 additions & 44 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/server/package.json

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010
},
1111
"scripts": {
1212
"test": "npx jest",
13-
"debug": "tsc-watch --onSuccess \"node --inspect-brk ./lib/example/simple.js\"",
14-
"start": "tsc-watch --onSuccess \"node ./lib/example/simple.js\"",
13+
"debug": "tsc-watch --onSuccess \"node --inspect-brk ./lib/example/simple.s3.js\"",
14+
"start": "tsc-watch --onSuccess \"node ./lib/example/simple.s3.js\"",
15+
"start:dynamodb": "tsc-watch --onSuccess \"node ./lib/example/simple.dynamodb.js\"",
1516
"start:advanced": "tsc-watch --onSuccess \"node ./lib/example/advanced.js\"",
1617
"type-check": "tsc --noEmit",
1718
"type-check:watch": "npm run type-check -- --watch",
@@ -33,24 +34,24 @@
3334
"dependencies": {
3435
"@types/lowdb": "1.0.9",
3536
"@types/pino": "6.3.3",
36-
"ajv": "^7.0.0",
37+
"ajv": "^7.0.3",
3738
"cors": "^2.8.5",
3839
"express": "^4.17.1",
3940
"express-graphql": "^0.12.0",
4041
"express-list-endpoints": "^5.0.0",
4142
"graphql": "^15.4.0",
42-
"helmet": "^4.2.0",
43+
"helmet": "^4.3.1",
4344
"json-server": "^0.16.3",
4445
"lowdb": "^1.0.0",
4546
"lowdb-adapter-aws-s3": "^1.1.2",
4647
"node-fetch": "^2.6.0",
4748
"passport": "^0.4.1",
4849
"passport-headerapikey": "^1.2.2",
49-
"pino": "^6.7.0",
50+
"pino": "^6.9.0",
5051
"serverless-http": "^2.6.0",
5152
"swagger-to-graphql": "^4.0.2",
52-
"swagger-ui-express": "^4.1.5",
53-
"table": "^6.0.4"
53+
"swagger-ui-express": "^4.1.6",
54+
"table": "^6.0.6"
5455
},
5556
"devDependencies": {
5657
"@types/aws-lambda": "8.10.64",
@@ -61,10 +62,8 @@
6162
"@types/express-serve-static-core": "4.17.13",
6263
"@types/jest": "26.0.15",
6364
"@types/json-server": "0.14.2",
64-
"@types/lowdb": "1.0.9",
6565
"@types/node": "10.14.16",
6666
"@types/passport": "1.0.4",
67-
"@types/pino": "6.3.3",
6867
"@types/supertest": "2.0.10",
6968
"@types/swagger-schema-official": "2.0.21",
7069
"@types/swagger-ui-express": "4.1.2",

0 commit comments

Comments
 (0)