Skip to content

Commit

Permalink
Support serverless-appsync-plugin v2 (#183)
Browse files Browse the repository at this point in the history
feat: Support serverless-appsync-plugin v2
feat: Added support for Node 20 
feat: Rewrite in TypeScript

BREAKING CHANGE: Dropped support for serverless-appsync-plugin v1
BREAKING CHANGE: Dropped support for Node < 18
---------
Co-authored-by: Pierre Lezan <[email protected]>
  • Loading branch information
horiuchi and Pierre Lezan committed Jan 24, 2024
1 parent 1337fb4 commit d2a33a9
Show file tree
Hide file tree
Showing 37 changed files with 6,717 additions and 4,215 deletions.
18 changes: 0 additions & 18 deletions .babelrc

This file was deleted.

1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
42 changes: 42 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"root": true,
"env": {
"jest": true,
"node": true,
"es6": true
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig_test.json"
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"prettier"
],
"plugins": ["@typescript-eslint", "import", "unused-imports"],
"rules": {
"prefer-const": "error",
"no-var": "error",
"no-console": "off",
"sort-imports": "off",
"import/order": [
"error",
{
"alphabetize": {
"order": "asc",
"caseInsensitive": true
}
}
],
"class-methods-use-this": "error",
"unused-imports/no-unused-imports": "error",
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/no-unused-vars": "off"
},
"ignorePatterns": [
"lib/**/*",
"node_modules"
]
}
13 changes: 0 additions & 13 deletions .eslintrc.yml

This file was deleted.

1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- master
- beta

jobs:
publish:
Expand Down
3 changes: 2 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"tabWidth": 2,
"useTabs": false,
"singleQuote": true,
"trailingComma": "all"
"trailingComma": "all",
"endOfLine": "auto"
}
11 changes: 11 additions & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { JestConfigWithTsJest } from 'ts-jest';

const config: JestConfigWithTsJest = {
preset: 'ts-jest',
testEnvironment: 'node',
silent: true,
moduleDirectories: ['node_modules', 'src'],
transformIgnorePatterns: ['[/\\\\]node_modules[/\\\\].+\\.(js|jsx|ts|tsx)$'],
};

export default config;
75 changes: 44 additions & 31 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,46 +11,59 @@
"url": "git+https://github.com/serverless-appsync/serverless-appsync-simulator.git"
},
"scripts": {
"lint": "eslint src/*/**.js",
"tests": "jest",
"build": "babel src/ -d lib/ --delete-dir-on-start --ignore '**/__tests__'",
"prepare": "yarn run build",
"build": "tsc -p .",
"watch": "yarn run build -w",
"lint": "eslint . && tsc --noEmit",
"prepare": "rm -rf lib && yarn run build",
"start-dev": "yarn run build -w --verbose"
},
"files": [
"/lib"
],
"dependencies": {
"@graphql-tools/merge": "^8.2.1",
"amplify-appsync-simulator": "^1.27.4",
"amplify-nodejs-function-runtime-provider": "^1.1.6",
"aws-sdk": "^2.792.0",
"axios": "^0.21.0",
"babel-jest": "^26.6.3",
"bluebird": "^3.7.2",
"cfn-resolver-lib": "^1.1.7",
"dataloader": "^2.0.0",
"fb-watchman": "^2.0.1",
"globby": "^11.0.3",
"jest": "^26.6.3",
"lodash": "^4.17.20",
"mysql2": "^2.2.5",
"pg": "^8.6.0"
"@graphql-tools/merge": "^8.4.0",
"amplify-appsync-simulator": "^2.4.1",
"amplify-nodejs-function-runtime-provider": "^2.3.13",
"aws-sdk": "^2.1341.0",
"axios": "^1.3.4",
"cfn-resolver-lib": "^1.1.8",
"dataloader": "^2.2.2",
"fb-watchman": "^2.0.2",
"globby": "^11.1.0",
"graphql": "^16.6.0",
"graphql-tools": "^8.3.19",
"lodash": "^4.17.21",
"mysql2": "^2.3.3",
"pg": "^8.10.0",
"ts-toolbelt": "^9.6.0"
},
"devDependencies": {
"@babel/cli": "^7.12.1",
"@babel/core": "^7.12.3",
"@babel/plugin-transform-modules-commonjs": "^7.12.1",
"@babel/preset-env": "^7.12.1",
"@semantic-release/git": "^9.0.0",
"all-contributors-cli": "^6.19.0",
"babel-eslint": "^10.1.0",
"babel-plugin-inline-import": "^3.0.0",
"eslint": "^7.13.0",
"eslint-config-prettier": "^7.0.0",
"eslint-plugin-prettier": "^3.2.0",
"prettier": "^2.2.1",
"semantic-release": "19"
"@semantic-release/git": "^10.0.1",
"@serverless/typescript": "^3.27.0",
"@types/fb-watchman": "^2.0.1",
"@types/jest": "^29.5.0",
"@types/lodash": "^4.14.191",
"@types/node": "^16.18.18",
"@types/pg": "^8.6.6",
"@typescript-eslint/eslint-plugin": "^5.56.0",
"@typescript-eslint/parser": "^5.56.0",
"all-contributors-cli": "^6.24.0",
"eslint": "^8.36.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-unused-imports": "^2.0.0",
"jest": "^29.5.0",
"prettier": "^2.8.6",
"semantic-release": "^20.1.3",
"serverless": "^3.28.1",
"ts-jest": "^29.0.5",
"ts-node": "^10.9.1",
"typescript": "^4.9.5"
},
"peerDependencies": {
"serverless": "3"
},
"keywords": [
"serverless",
Expand Down
127 changes: 127 additions & 0 deletions src/__tests__/__snapshots__/config.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`resolveConfiguration should generate a valid config 1`] = `
{
"additionalAuthentications": [
{
"config": {
"userPoolId": "us-west-2_123456789",
},
"type": "AMAZON_COGNITO_USER_POOLS",
},
],
"apiKeys": {
"foo-bar": {
"name": "foo-bar",
},
},
"authentication": {
"type": "API_KEY",
},
"dataSources": {
"dynamodb": {
"config": {
"tableName": "myTable",
},
"name": "dynamodb",
"type": "AMAZON_DYNAMODB",
},
"http": {
"config": {
"endpoint": "http://127.0.0.1",
},
"name": "http",
"type": "HTTP",
},
"lambda": {
"config": {
"functionName": "resolver",
},
"name": "lambda",
"type": "AWS_LAMBDA",
},
"none": {
"name": "none",
"type": "NONE",
},
},
"name": "myAPI",
"pipelineFunctions": {
"func": {
"dataSource": "lambda",
"name": "func",
"request": "src/__tests__/files/mapping-templates/templates.request.vtl",
"response": "src/__tests__/files/mapping-templates/templates.response.vtl",
"substitutions": {
"mySubVar": "template-function",
},
},
"funcDirect": {
"dataSource": "lambda",
"name": "funcDirect",
},
},
"resolvers": {
"Mutation.updateNode": {
"dataSource": "lambda",
"field": "updateNode",
"kind": "UNIT",
"type": "Mutation",
},
"Query.node": {
"dataSource": "lambda",
"field": "node",
"kind": "UNIT",
"type": "Query",
},
"Query.pipeline": {
"field": "pipeline",
"functions": [
"func",
"funcDirect",
],
"kind": "PIPELINE",
"type": "Query",
},
"Query.templates": {
"dataSource": "lambda",
"field": "templates",
"kind": "UNIT",
"request": "src/__tests__/files/mapping-templates/templates.request.vtl",
"response": "src/__tests__/files/mapping-templates/templates.response.vtl",
"substitutions": {
"mySubVar": "lambda",
},
"type": "Query",
},
},
"schema": [
"src/__tests__/files/*.graphql",
],
}
`;

exports[`resolveConfiguration should generate a valid config 2`] = `
{
"apiKey": "0123456789",
"dynamoDb": {
"accessKeyId": "DEFAULT_ACCESS_KEY",
"endpoint": "http://localhost:8000",
"region": "localhost",
"secretAccessKey": "DEFAULT_SECRET",
},
"getAttMap": {},
"importValueMap": {},
"lambdaPort": 3002,
"location": ".",
"openSearch": {},
"port": 20002,
"rds": {},
"refMap": {},
"watch": [
"*.graphql",
"*.vtl",
],
"wsPort": 20003,
}
`;
Loading

0 comments on commit d2a33a9

Please sign in to comment.