File tree 8 files changed +86
-7
lines changed
8 files changed +86
-7
lines changed Original file line number Diff line number Diff line change 1
1
node_modules
2
2
.sst
3
3
.build
4
+ yarn-error.log
Original file line number Diff line number Diff line change 2
2
"name" : " @acme/frontend" ,
3
3
"version" : " 0.0.0" ,
4
4
"scripts" : {
5
- "dev" : " vite" ,
5
+ "dev" : " sst-env -- vite" ,
6
6
"build" : " tsc && vite build" ,
7
7
"preview" : " vite preview"
8
8
},
12
12
"urql" : " ^2.0.6"
13
13
},
14
14
"devDependencies" : {
15
+ "@serverless-stack/static-site-env" : " ^0.56.2" ,
15
16
"@types/react" : " ^17.0.33" ,
16
17
"@types/react-dom" : " ^17.0.10" ,
17
18
"@vitejs/plugin-react" : " ^1.0.7" ,
Original file line number Diff line number Diff line change
1
+ export const Config = {
2
+ APOLLO_URL : import . meta. env . VITE_APOLLO_URL as string ,
3
+ } ;
4
+ console . log ( "Config" , Config ) ;
Original file line number Diff line number Diff line change @@ -3,9 +3,10 @@ import ReactDOM from "react-dom";
3
3
4
4
import { Todos } from "./pages/Todos" ;
5
5
import * as urql from "urql" ;
6
+ import { Config } from "./config" ;
6
7
7
8
const client = urql . createClient ( {
8
- url : "https://d7nn8pnx3g.execute-api.us-east-2.amazonaws.com" ,
9
+ url : Config . APOLLO_URL ,
9
10
} ) ;
10
11
11
12
ReactDOM . render (
Original file line number Diff line number Diff line change 1
1
import * as sst from "@serverless-stack/resources" ;
2
2
3
3
export class Api extends sst . Stack {
4
+ public readonly outputs : {
5
+ apollo : string ;
6
+ } ;
7
+
4
8
constructor ( scope : sst . App ) {
5
- super ( scope , "gql " ) ;
9
+ super ( scope , "api " ) ;
6
10
7
11
const apollo = new sst . ApolloApi ( this , "apollo" , {
8
12
server : "services/apollo/apollo.handler" ,
9
13
} ) ;
10
14
11
- this . addOutputs ( {
12
- Apollo : apollo . url ,
13
- } ) ;
15
+ this . outputs = {
16
+ apollo : apollo . url ,
17
+ } ;
14
18
}
15
19
}
Original file line number Diff line number Diff line change
1
+ import * as sst from "@serverless-stack/resources" ;
2
+ import { Api } from "./Api" ;
3
+
4
+ type Props = {
5
+ api : Api [ "outputs" ] ;
6
+ } ;
7
+
8
+ export class Frontend extends sst . Stack {
9
+ constructor ( scope : sst . App , props : Props ) {
10
+ super ( scope , "frontend" ) ;
11
+
12
+ const site = new sst . StaticSite ( this , "frontend" , {
13
+ path : "frontend" ,
14
+ environment : {
15
+ VITE_APOLLO_URL : props . api . apollo ,
16
+ } ,
17
+ } ) ;
18
+
19
+ this . addOutputs ( {
20
+ Site : site . url ,
21
+ } ) ;
22
+ }
23
+ }
Original file line number Diff line number Diff line change 1
1
import * as sst from "@serverless-stack/resources" ;
2
2
import { Api } from "./Api" ;
3
+ import { Frontend } from "./Frontend" ;
3
4
4
5
export default function main ( app : sst . App ) : void {
5
6
app . setDefaultFunctionProps ( {
@@ -8,5 +9,8 @@ export default function main(app: sst.App): void {
8
9
environment : { } ,
9
10
} ) ;
10
11
11
- new Api ( app ) ;
12
+ const api = new Api ( app ) ;
13
+ new Frontend ( app , {
14
+ api : api . outputs ,
15
+ } ) ;
12
16
}
Original file line number Diff line number Diff line change 5176
5176
xstate "^4.26.1"
5177
5177
zod "^3.11.6"
5178
5178
5179
+ "@serverless-stack/core@^0.56.2":
5180
+ version "0.56.2"
5181
+ resolved "https://registry.yarnpkg.com/@serverless-stack/core/-/core-0.56.2.tgz#a552aa12345055eec84ddaff1da595aa8b601108"
5182
+ integrity sha512-67n9vGOn9KIHCXDED3E5eUKfFgOyejisaA3Iy0+7ybI9sdDFN49rrj/F/SQWm0YlnfDD7wak0l4CaMa1iBD/fw==
5183
+ dependencies:
5184
+ "@aws-sdk/client-s3" "^3.45.0"
5185
+ "@trpc/client" "^9.16.0"
5186
+ "@trpc/react" "^9.16.0"
5187
+ "@trpc/server" "^9.16.0"
5188
+ "@types/picomatch" "^2.3.0"
5189
+ aws-cdk "1.132.0"
5190
+ aws-sdk "^2.761.0"
5191
+ chalk "^4.1.0"
5192
+ chokidar "^3.5.2"
5193
+ cross-spawn "^7.0.3"
5194
+ dataloader "^2.0.0"
5195
+ dendriform-immer-patch-optimiser "^2.1.0"
5196
+ dotenv "^10.0.0"
5197
+ dotenv-expand "^5.1.0"
5198
+ express "^4.17.1"
5199
+ fs-extra "^9.0.1"
5200
+ immer "^9.0.7"
5201
+ js-yaml "^4.1.0"
5202
+ log4js "^6.3.0"
5203
+ picomatch "^2.3.0"
5204
+ remeda "^0.0.32"
5205
+ stun "^2.1.0"
5206
+ typescript "^4.4.3"
5207
+ uuid "^8.3.2"
5208
+ xstate "^4.26.1"
5209
+ zod "^3.11.6"
5210
+
5179
5211
"@serverless-stack/nextjs-core@^0.1.9":
5180
5212
version "0.1.9"
5181
5213
resolved "https://registry.yarnpkg.com/@serverless-stack/nextjs-core/-/nextjs-core-0.1.9.tgz#ca480e8081df5d262ed5f61ef44584e130198e17"
5268
5300
typescript "^4.4.3"
5269
5301
zip-local "^0.3.4"
5270
5302
5303
+ "@serverless-stack/static-site-env@^0.56.2":
5304
+ version "0.56.2"
5305
+ resolved "https://registry.yarnpkg.com/@serverless-stack/static-site-env/-/static-site-env-0.56.2.tgz#4c972dc717722671c2a2b1d8ba32f4c950b37876"
5306
+ integrity sha512-SJ1AXu90oEgn4aaSJJGBeBeaeokLuMLIGKiGD8/tmW/QI72YYNzJNHu/mMHFokvNwl4Uxq3gmBclP39UyUaKYA==
5307
+ dependencies:
5308
+ "@serverless-stack/core" "^0.56.2"
5309
+ chalk "^4.1.0"
5310
+ yargs "^15.4.1"
5311
+
5271
5312
"@sindresorhus/is@^0.14.0":
5272
5313
version "0.14.0"
5273
5314
resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-0.14.0.tgz#9fb3a3cf3132328151f353de4632e01e52102bea"
You can’t perform that action at this time.
0 commit comments