Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add and export types to support serverless typescript configuration file. #78

Open
adjisb opened this issue Jul 7, 2023 · 1 comment

Comments

@adjisb
Copy link

adjisb commented Jul 7, 2023

When trying to use the serverless configuration with typescript, like: Building a serverless app with TypeScript you need the right typescript types to declare the configuration.

There are two projects that declare the types: https://www.npmjs.com/package/@types/serverless (the interface is called Serverless) and https://github.com/serverless/typescript (the interface is called AWS)

I didn't find an equivalent interface in the serverless defender plugin file https://github.com/OpenZeppelin/defender-serverless/blob/main/src/types/index.ts.

It will be helpful to have something like that exported.

@adjisb
Copy link
Author

adjisb commented Jul 10, 2023

This is the trick I'm using right now, it doesn't make sense to extend from AWS but I'm lazy.

import {YContract, YSentinel} from 'defender-serverless/src/types/index';
import {AWS} from '@serverless/typescript';
import {YNotification, YRelayer, YSecret} from 'defender-serverless/lib/types';

export interface DefenderServerless
  extends Omit<AWS, 'provider' | 'resources'> {
  provider: {
    name: 'defender';
    stage: string;
    stackName: string;
    ssot?: boolean;
  };
  defender: {
    key: string | undefined;
    secret: string | undefined;
  };
  resources?:
    | {
        Resources: {
          secrets?: {
            [contractName: string]: YSecret;
          };
          contracts?: {
            [contractName: string]: YContract;
          };
          sentinels?: {
            [contractName: string]: YSentinel;
          };
          notifications?: {
            [contractName: string]: YNotification;
          };
          relayers?: {
            [contractName: string]: YRelayer;
          };
        };
      }
    | undefined;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant