jamlen
03/17/2022, 10:53 AMTypeError: Cannot read property 'filename' of undefined
whenever I try to make a connectionArpad
03/17/2022, 1:28 PMDan Suceava
03/17/2022, 7:01 PMconst connection = await createConnection({
type: "aurora-data-api",
database: "mydatabase",
secretArn: process.env.AURORA_SECRET_ARN,
resourceArn: process.env.AURORA_CLUSTER_ARN,
entities: [
User,
Orders
],
});
Frank
AppSyncApi
on Windows. Do u happen to have the same setup by any chance?Sean Matheson
03/17/2022, 9:15 PMjamlen
03/21/2022, 6:10 PMsychronize: true
?jamlen
03/21/2022, 8:50 PM{
errorType: 'Runtime.UnhandledPromiseRejection',
errorMessage: "TypeError: Cannot read property 'filename' of undefined",
reason: "TypeError: Cannot read property 'filename' of undefined",
promise: {},
stack: [
"Runtime.UnhandledPromiseRejection: TypeError: Cannot read property 'filename' of undefined",
' at process.<anonymous> (file:///Users/jamlen/dev/src/github.com/tfgm/orm-test/node_modules/@serverless-stack/aws-lambda-ric/lib/index.js:34:23)',
' at process.emit (events.js:400:28)',
' at processPromiseRejections (internal/process/promises.js:245:33)',
' at processTicksAndRejections (internal/process/task_queues.js:96:32)'
]
}
Dan Suceava
03/21/2022, 9:59 PMsynchronize: true
although I did try it once and seemed to work. I make the connection in the Lambda handler, this is what my core handler looks like (this is from an early test):
import { APIGatewayProxyEventV2, APIGatewayProxyHandlerV2 } from "aws-lambda";
import { getDatabase } from "../domain/database/database";
export const handler: APIGatewayProxyHandlerV2 = async (event: APIGatewayProxyEventV2) => {
const message = event.body;
// connect to the database to perform the migration
let response = "";
try {
const db = await getDatabase({ synchronize: true });
response = "Database connected";
} catch (error: any) {
console.error(error);
response = error.message;
}
return {
statusCode: 200,
body: response,
};
};
the getDatabase()
call makes the connection as I posted aboveDan Suceava
03/21/2022, 10:00 PMjamlen
03/23/2022, 8:50 AMFrank
main
function inside ur stacks/index.ts
app.setDefaultFunctionProps({
bundle: {
nodeModules: ["typeorm"],
},
});
Frank
esbuild
.Frank
jamlen
03/25/2022, 11:34 AMtypeorm-aurora-data-api-driver
? I keep getting
MissingDriverError: Wrong driver: "aurora-data-api-pg" given. Supported drivers are: "aurora-mysql", "aurora-postgres", "better-sqlite3", "capacitor", "cockroachdb", "cordova", "expo", "mariadb", "mongodb", "mssql", "mysql", "nativescript", "oracle", "postgres", "react-native", "sap", "sqlite", "sqljs".
even though I have
"dependencies": {
"data-api-client": "^1.2.0",
"reflect-metadata": "^0.1.13",
"typeorm": "0.3.0",
"typeorm-aurora-data-api-driver": "^2.3.5"
}
Dan Suceava
03/25/2022, 1:38 PM"dependencies": {
"@aws-sdk/client-sfn": "^3.53.0",
"@aws-sdk/client-sns": "^3.50.0",
"@middy/core": "^2.5.7",
"@middy/http-error-handler": "^2.5.7",
"axios": "^0.25.0",
"http-errors": "^2.0.0",
"jsonwebtoken": "^8.5.1",
"md5": "^2.3.0",
"middy-middleware-jwt-auth": "^5.0.0",
"mysql2": "^2.3.3",
"reflect-metadata": "^0.1.13",
"typeorm": "^0.2.41",
"typeorm-aurora-data-api-driver": "^2.3.5"
},
Looks like tyeporm 0.3.0
was a big release, haven't tried it yetjamlen
04/01/2022, 12:02 PMjamlen
04/01/2022, 12:03 PM{
"errorType": "Runtime.UnhandledPromiseRejection",
"errorMessage": "ColumnTypeUndefinedError: Column type for Customer#firstName 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.",
}
jamlen
04/01/2022, 12:05 PMjamlen
04/01/2022, 12:15 PMDan Suceava
04/02/2022, 1:51 AMfirstName
& lastName
in the entity file:
@Column({ type: 'nvarchar', length: 100 })
firstName: string;