File tree Expand file tree Collapse file tree 5 files changed +31
-21
lines changed
Expand file tree Collapse file tree 5 files changed +31
-21
lines changed Original file line number Diff line number Diff line change @@ -67,7 +67,22 @@ yarn deploy
6767
6868## Setting up a Lambda endpoint manually
6969
70- If you prefer not to use the serverless.js framewwork, you can also deploy your lambda function manually.
70+ If you prefer not to use the serverless.js framework, you can also deploy your lambda function manually.
71+
72+ Note 1: Change your process.env.AWS_STAGE_NAME to "/default" to match the default stage name for manually deployed API Gateways.
73+
74+ Note 2: To enable cors with a manual deployment, you should add cors middleware to the top of combineMiddleware() in index.js.
75+
76+ ```
77+ const cors = require('cors');
78+ const app = combineMiddlewares([
79+ // CORS middleware to permit cross-site API requests. Configure to taste
80+ cors(),
81+
82+ (req, res, next) => { ... },
83+ postgraphile(...)
84+ ...
85+ ```
7186
72870 . Run ` yarn build ` to create ` lambda.zip ` file that you can upload to Amazon Lambda.
73881 . Visit https://console.aws.amazon.com/lambda/home and click 'Create function'
Original file line number Diff line number Diff line change @@ -3,26 +3,22 @@ const s3 = new aws.S3();
33
44const bucketName = process . env . AWS_SERVICE_NAME ;
55
6- s3 . listBuckets ( ( err , data ) => {
7- if ( err ) {
8- console . log ( 'Error' , err ) ;
9- process . exit ( 1 ) ;
10- }
6+ async function main ( ) {
7+ const { Buckets } = await s3 . listBuckets ( ) . promise ( ) ;
118
12- if ( data . Buckets . find ( bucket => bucket . Name === bucketName ) ) {
9+ if ( Buckets . find ( bucket => bucket . Name === bucketName ) ) {
1310 console . log ( `Bucket "${ bucketName } " already exists.` ) ;
1411 } else {
1512 const bucketParams = {
1613 Bucket : bucketName
1714 } ;
1815
19- s3 . createBucket ( bucketParams , ( err , data ) => {
20- if ( err ) {
21- console . log ( `Bucket "${ bucketName } " failed to build.` , err ) ;
22- process . exit ( 1 ) ;
23- } else {
24- console . log ( `Bucket "${ bucketName } " built in region ${ data . Location } ` ) ;
25- }
26- } ) ;
16+ await s3 . createBucket ( bucketParams ) . promise ( ) ;
17+ console . log ( `Bucket "${ bucketName } " created.` ) ;
2718 }
19+ } ;
20+
21+ main ( ) . catch ( err => {
22+ console . log ( 'Error' , err ) ;
23+ process . exit ( 1 ) ;
2824} ) ;
Original file line number Diff line number Diff line change 11#! /bin/bash
2+ set -e
23CURRENT_DIR=` dirname $BASH_SOURCE `
34
45# Source env variables
@@ -7,15 +8,15 @@ if [ -x .env ]; then
78 . ./.env
89 echo " ... done"
910else
10- echo " ... no .env file found"
11+ echo " ... no executable .env file found"
1112fi
1213
1314if [ " $DATABASE_URL " = " " ]; then
1415 echo " No DATABASE_URL envvar found; cannot continue."
1516 exit 1
1617fi
1718
18- rm -rf .serverless
19+ rm -rf $CURRENT_DIR /../ .serverless
1920
2021echo " Phase 1: Create serverless package"
2122sls package
Original file line number Diff line number Diff line change @@ -2,20 +2,18 @@ exports.options = {
22 dynamicJson : true ,
33 cors : true ,
44 graphiql : false ,
5- externalUrlBase : '' ,
65 graphqlRoute : '/graphql' ,
6+ externalUrlBase : `/${ process . env . AWS_STAGE } ` ,
77
88 // If consuming JWT:
99 jwtSecret : process . env . JWT_SECRET || String ( Math . random ( ) ) ,
1010 // If generating JWT:
11- jwtPgTypeIdentifier : 'floods.jwt_token' ,
12- pgDefaultRole : 'floods_anonymous' ,
11+ jwtPgTypeIdentifier : 'forum_example.jwt_token' ,
1312
1413 /* If you want to enable GraphiQL, you must use `externalUrlBase` so PostGraphile
1514 * knows where to tell the browser to find the assets. Doing this is
1615 * strongly discouraged, you should use an external GraphQL client instead.
1716
18- externalUrlBase: '/default',
1917 graphiql: true,
2018 enhanceGraphiql: true,
2119 graphqlRoute: '/',
You can’t perform that action at this time.
0 commit comments