-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: #374 deploy graphql to lambda
- Loading branch information
Duong Pham
committed
Feb 25, 2020
1 parent
d63f431
commit c50b261
Showing
6 changed files
with
1,040 additions
and
69 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
service: graphql-server | ||
plugins: | ||
- serverless-webpack | ||
custom: | ||
env: ${file(../../reapit-config.json)} | ||
|
||
provider: | ||
name: aws | ||
runtime: nodejs10.x | ||
stage: ${opt:stage, 'dev'} | ||
region: eu-west-2 | ||
deploymentBucket: | ||
name: graphql-server.${self:provider.stage} | ||
blockPublicAccess: false | ||
environment: | ||
NODE_ENV: ${self:custom.env.${self:provider.stage}.NODE_ENV} | ||
COGNITO_USERPOOL_ID: ${self:custom.${file(./yml-helpers.js):provider.stage.uppercase}.COGNITO_USERPOOL_ID} | ||
MARKET_PLACE_URL: ${self:custom.${file(./yml-helpers.js):provider.stage.uppercase}.MARKET_PLACE_URL} | ||
|
||
package: | ||
include: | ||
- dist/** | ||
- node_modules/** | ||
- package.json | ||
exclude: | ||
- error.log | ||
- info.log | ||
- jest.config.js | ||
- nodemon.json | ||
- serverless.yml | ||
- src/** | ||
- tsconfig.json | ||
|
||
functions: | ||
graphqlHandler: | ||
handler: dist/index.graphqlHandler | ||
events: | ||
- http: ANY / | ||
- http: 'ANY {proxy+}' |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import serverless from 'serverless-http' | ||
import { Context, Handler } from 'aws-lambda' | ||
import { server } from './app' | ||
|
||
const app = serverless(server as any) | ||
|
||
export const graphqlHandler: Handler<any, any> = async (event: any, context: Context) => app(event, context) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// https://stackoverflow.com/questions/48226686/serverless-yml-touppercase#48249468 | ||
module.exports.provider = serverless => { | ||
// The `serverless` argument containers all the information in the .yml file | ||
const provider = serverless.service.provider | ||
|
||
return Object.entries(provider).reduce( | ||
(accumulator, [key, value]) => ({ | ||
...accumulator, | ||
[key]: | ||
typeof value === 'string' | ||
? { | ||
lowercase: value.toLowerCase(), | ||
uppercase: value.toUpperCase(), | ||
} | ||
: value, | ||
}), | ||
{}, | ||
) | ||
} |
Oops, something went wrong.