Hello, I’m trying to integrate TypeORM and typeorm...
# help
a
Hello, I’m trying to integrate TypeORM and typeorm-aurora-data-api-driver with SST. Right now I’m getting
Copy code
{
  "errorType": "Runtime.UnhandledPromiseRejection",
  "errorMessage": "ColumnTypeUndefinedError: Column type for Job#title is not defined and cannot be guessed. Make sure you have turned on an \"emitDecoratorMetadata\": true option in tsconfig.json. Also make sure you have imported \"reflect-metadata\" on top of the main entry file in your application (before any entity imported).If you are using JavaScript instead of TypeScript you must explicitly provide a column type.",
  "reason": "ColumnTypeUndefinedError: Column type for Job#title is not defined and cannot be guessed. Make sure you have turned on an \"emitDecoratorMetadata\": true option in tsconfig.json. Also make sure you have imported \"reflect-metadata\" on top of the main entry file in your application (before any entity imported).If you are using JavaScript instead of TypeScript you must explicitly provide a column type.",
  "promise": {},
  "stack": [
    "Runtime.UnhandledPromiseRejection: ColumnTypeUndefinedError: Column type for Job#title is not defined and cannot be guessed. Make sure you have turned on an \"emitDecoratorMetadata\": true option in tsconfig.json. Also make sure you have imported \"reflect-metadata\" on top of the main entry file in your application (before any entity imported).If you are using JavaScript instead of TypeScript you must explicitly provide a column type.",
    "    at process.<anonymous> (file:///Users/ayeressian/personal/my-sst-app/node_modules/@serverless-stack/aws-lambda-ric/lib/index.js:34:23)",
    "    at process.emit (events.js:376:20)",
    "    at processPromiseRejections (internal/process/promises.js:245:33)",
    "    at processTicksAndRejections (internal/process/task_queues.js:96:32)"
  ]
}
Function
Copy code
...
const api = new sst.Api(this, "Api", {
      routes: {
        "GET /": {
          function: {
            handler: "src/function/db.handler",
            environment: {
              DATABASE,
              CLUSTER_ARN: cluster.clusterArn,
              SECRET_ARN: cluster.secret!.secretArn,
            },
            bundle: {
              esbuildConfig: {
                plugins: "./esbuild-config.js",
              },
              nodeModules: ["typeorm", "typeorm-aurora-data-api-driver"],
            },
            permissions: [cluster],
          },
        },
      },
    });
tsconfig.json
Copy code
{
  "compilerOptions": {
    "experimentalDecorators": true
  },
  "extends": "@tsconfig/node14",
  "include": [
    "stacks",
    "src"
  ]
}
Any help would be appreciated.
a
You probably need to emit metadata from your decorators too.
Copy code
/* Experimental Options */
    "experimentalDecorators": true,           /* Enables experimental support for ES7 decorators. */
    "emitDecoratorMetadata": true,            /* Enables experimental support for emitting type metadata for decorators. */
The path specified for esbuild-config.js indicates that it is at the level of package.json and sst.json. It is defining @anatine/esbuild-decorators?
a
@Adam Fanello silly me 🤦‍♂️ “emitDecoratorMetadata”: true, did the trick. Thank you!