I’ll just start a migration thread here, since I’m...
# help
s
I’ll just start a migration thread here, since I’m sure I’ll have more questions.. 🙂 starting with this: I can’t get
sst.Api
customDomain working:
Copy code
Type '{ cdk: { domainName: string; certificate: acm.ICertificate; }; }' is not assignable to type 'string | ApiDomainProps | undefined'.
      The types of 'cdk.domainName' are incompatible between these types.
        Type 'string' is not assignable to type 'IDomainName'.ts(2345)
the documentation says domainName can be a string, yet it’s complaining about that
t
hey custom domain is something native to sst so you don't have to put it inside the
cdk
prop
s
weird, it was yelling at me a minute ago 🤔 maybe it was the
certificate
prop it didn’t like, which does belong in
cdk
I’m also getting this error which I can’t make sense of:
Copy code
Type 'Record<string, ApiAuthorizer>' is not assignable to type 'Record<string, never>'.
    'string' index signatures are incompatible.
      Type 'ApiAuthorizer' is not assignable to type 'never'.
        Type 'ApiUserPoolAuthorizer' is not assignable to type 'never'.ts(2322)
Copy code
authorizers: {
        userPoolAuthorizer: {
          type: 'user_pool',
          userPool: {
            id: props.cognitoAuth.cdk.userPool.userPoolId,
            clientIds: [props.cognitoAuth.cdk.userPoolClient.userPoolClientId],
          },
        },
      },
hmm. I’m following the docs here: https://docs.serverless-stack.com/constructs/v1/Api#using-cognito-user-pool-as-the-jwt-authorizer nothing I’ve tried is working as expected. e.g., for
defaults.authorizer
, the only values I can choose from are “iam” or “none”. but the docs seem to indicate I can specify my custom authorizer
ah! got it. it’s because I was doing
this.restApi = new sst.Api(…)
and had previously typed this as:
Copy code
public readonly restApi: sst.Api;
but I had to change that to:
Copy code
public readonly restApi: sst.Api<{
    userPoolAuthorizer: {
      type: 'user_pool';
      userPool: {
        id: any;
        clientIds: any[];
      };
    };
  }>;
and then it worked
what’s wrong with the
targets
definition here?
Copy code
Type '{ function: { functionName: string; handler: string; environment: { GRAPHQL_ENDPOINT_URL: string; STAGING_BUCKET: string; }; permissions: ([GraphqlApi, string] | [Bucket, string])[]; }; }[]' is not assignable to type 'Record<string, Queue | FunctionInlineDefinition | EventBusFunctionTargetProps | EventBusQueueTargetProps>'.
  Index signature for type 'string' is missing in type '{ function: { functionName: string; handler: string; environment: { GRAPHQL_ENDPOINT_URL: string; STAGING_BUCKET: string; }; permissions: ([GraphqlApi, string] | [Bucket, string])[]; }; }[]'.ts(2322)
never mind. it seems the migration doc is out of sync w/ the API docs
f
Updated the doc
s
@Frank nice! thanks!