https://serverless-stack.com/ logo
#help
Title
# help
d

Daniel Gato

01/15/2022, 8:49 PM
This is a stupid question - in the guide you say to do this:
Copy code
export default class ApiStack extends sst.Stack {
  api;

  constructor(scope, id, props) {
    super(scope, id, props);
    ...
Why do we expose api? Is there any requirement of SST for us to do that?
t

thdxr

01/15/2022, 8:50 PM
only if you're passing it to another stack to reference
d

Daniel Gato

01/15/2022, 8:54 PM
we need it because of this :
Copy code
const apiStack = new ApiStack(app, 'api', {...});
  const authStack = new AuthStack(app, 'auth', {
    api: apiStack.api,
    uploadsBucket: storageStack.uploadsBucket,
  });
?
t

thdxr

01/15/2022, 8:58 PM
yep sounds right
d

Daniel Gato

01/15/2022, 9:00 PM
Hum I removed the reference but it still works and detects no build change
f

Frank

01/16/2022, 7:43 AM
Can I see how you are using the api inside the AuthStack?
d

Daniel Gato

01/16/2022, 2:14 PM
Copy code
export default class AuthStack extends sst.Stack {
  auth;

  constructor(scope, id, props) {
    super(scope, id, props);

    const { api, uploadsBucket } = props;

    this.auth = new sst.Auth(this, 'Auth', { ... });

    this.auth.attachPermissionsForAuthUsers([
      api,
      // ...
    ]);
    // ...
  }
}