Giorgio
06/11/2022, 6:53 PMe8a5a024-b37d-4ce6-b85e-d0d7ee454267 REQUEST dev-dolartec-app-db-DatabaseMigrationFunction9CBE9-qOutRhPjrpC9 [index.handler] invoked
(node:19518) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use `node --trace-warnings ...` to show where the warning was created)
e8a5a024-b37d-4ce6-b85e-d0d7ee454267 ERROR Runtime.UnhandledPromiseRejection: Runtime.UserCodeSyntaxError: SyntaxError: Cannot use import statement outside a module
thdxr
06/11/2022, 6:53 PMGiorgio
06/11/2022, 7:03 PM20220610210900_cleanup.mjs
e8d7e450-ef09-41a4-9ca9-85d74941bd38 RESPONSE {"results":[{"migrationName":"20220610210900_cleanup","direction":"Up","status":"Success"}]}
505e446a-7f0b-44f7-b389-135ff932f5b0 RESPONSE [{"name":"20220610210900_cleanup","migration":{},"executedAt":"2022-06-11T19:01:56.582Z"}]
BadRequestException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'schemas AS (
SELECT nspname AS name, oid AS oid
FROM pg_namespac' at line 1; Error code: 1064; SQLState: 42000
at Object.extractError (/Users/giorgioleveroni/Projects/dolartec/node_modules/.pnpm/aws-sdk@2.1152.0/node_modules/aws-sdk/lib/protocol/json.js:52:27)
at Request.extractError (/Users/giorgioleveroni/Projects/dolartec/node_modules/.pnpm/aws-sdk@2.1152.0/node_modules/aws-sdk/lib/protocol/rest_json.js:49:8)
at Request.callListeners (/Users/giorgioleveroni/Projects/dolartec/node_modules/.pnpm/aws-sdk@2.1152.0/node_modules/aws-sdk/lib/sequential_executor.js:106:20)
at Request.emit (/Users/giorgioleveroni/Projects/dolartec/node_modules/.pnpm/aws-sdk@2.1152.0/node_modules/aws-sdk/lib/sequential_executor.js:78:10)
at Request.emit (/Users/giorgioleveroni/Projects/dolartec/node_modules/.pnpm/aws-sdk@2.1152.0/node_modules/aws-sdk/lib/request.js:686:14)
at Request.transition (/Users/giorgioleveroni/Projects/dolartec/node_modules/.pnpm/aws-sdk@2.1152.0/node_modules/aws-sdk/lib/request.js:22:10)
at AcceptorStateMachine.runTo (/Users/giorgioleveroni/Projects/dolartec/node_modules/.pnpm/aws-sdk@2.1152.0/node_modules/aws-sdk/lib/state_machine.js:14:12)
at /Users/giorgioleveroni/Projects/dolartec/node_modules/.pnpm/aws-sdk@2.1152.0/node_modules/aws-sdk/lib/state_machine.js:26:10
at Request.<anonymous> (/Users/giorgioleveroni/Projects/dolartec/node_modules/.pnpm/aws-sdk@2.1152.0/node_modules/aws-sdk/lib/request.js:38:9)
at Request.<anonymous> (/Users/giorgioleveroni/Projects/dolartec/node_modules/.pnpm/aws-sdk@2.1152.0/node_modules/aws-sdk/lib/request.js:688:12)
at Request.callListeners (/Users/giorgioleveroni/Projects/dolartec/node_modules/.pnpm/aws-sdk@2.1152.0/node_modules/aws-sdk/lib/sequential_executor.js:116:18)
at Request.emit (/Users/giorgioleveroni/Projects/dolartec/node_modules/.pnpm/aws-sdk@2.1152.0/node_modules/aws-sdk/lib/sequential_executor.js:78:10)
at Request.emit (/Users/giorgioleveroni/Projects/dolartec/node_modules/.pnpm/aws-sdk@2.1152.0/node_modules/aws-sdk/lib/request.js:686:14)
at Request.transition (/Users/giorgioleveroni/Projects/dolartec/node_modules/.pnpm/aws-sdk@2.1152.0/node_modules/aws-sdk/lib/request.js:22:10)
at AcceptorStateMachine.runTo (/Users/giorgioleveroni/Projects/dolartec/node_modules/.pnpm/aws-sdk@2.1152.0/node_modules/aws-sdk/lib/state_machine.js:14:12)
at /Users/giorgioleveroni/Projects/dolartec/node_modules/.pnpm/aws-sdk@2.1152.0/node_modules/aws-sdk/lib/state_machine.js:26:10
Giorgio
06/11/2022, 7:04 PMpnpm
requires me to explicitly add a few more packages in order to run:
aws-sdk
, kysely
, kysely-data-api
, @serverless-stack/core
Giorgio
06/11/2022, 7:05 PMthdxr
06/11/2022, 7:05 PMGiorgio
06/11/2022, 7:06 PMUserCodeSyntaxError
error before or if I'm following a red herring)thdxr
06/11/2022, 7:06 PMGiorgio
06/11/2022, 7:06 PMGiorgio
06/11/2022, 7:06 PMGiorgio
06/11/2022, 7:10 PMthdxr
06/11/2022, 7:23 PMGiorgio
06/11/2022, 7:36 PMYou have an error in your SQL syntax
, and I'm running it on a migration file with empty up
and down
functions.Giorgio
06/11/2022, 7:52 PM"type": "module",
inside the root package.json
in addition to the one in the backend
folder which isn't included in the templateGiorgio
06/11/2022, 8:37 PMpostgresql10.14
Giorgio
06/11/2022, 8:38 PMPostgresIntrospector
https://github.com/koskimas/kysely/blob/c8fe7915b94bf42dbb475a45614792e4e748be14/src/dialect/postgres/postgres-introspector.ts#L25Giorgio
06/11/2022, 8:39 PMmode
parameter https://github.com/serverless-stack/kysely-data-api/blob/master/src/data-api-dialect.ts#L31Giorgio
06/11/2022, 8:40 PMGiorgio
06/11/2022, 8:41 PMGiorgio
06/11/2022, 9:52 PMGiorgio
06/11/2022, 9:58 PMtypes: "backend/sql.generated.ts",
Giorgio
06/11/2022, 9:59 PMGiorgio
06/11/2022, 10:00 PMthdxr
06/11/2022, 11:47 PMthdxr
06/11/2022, 11:47 PMthdxr
06/11/2022, 11:47 PMGiorgio
06/12/2022, 1:59 AMsst deploy --stage prod
. It might be because of pnpm again, I'm running them with yarn now and see how it goes:
'../.pnpm/@serverless-stack+resources@1.2.20/@serverless-stack/resources/dist/RDS_migrator/index.handler' is not a valid handler name. Use absolute paths when specifying root directories in handler names.
Giorgio
06/12/2022, 2:28 AMthdxr
06/12/2022, 1:32 PMGiorgio
06/12/2022, 5:24 PMsst deploy
I realized that it doesn't work with a different directory layout where the lambdas are outside the SST directory. I have the following layout:
.
infrastructure/ (SST)
lambdas/ (all the backend logic)
frontend/ (Expo)
api/ (GraphQL schema + generated .ts typedef file)
common/ logic shared between frontend and lambdas (mainly validations so frontend can also use it in the forms)
so in infrastructure/index.ts
I'd then define srcPath: '../lambdas'
but I'm hit with an error similar to the one previously mentioned. Might be because ESM is more strict on these things? I'm not sure. I ended up moving lambdas
to infrastructure/backend
.thdxr
06/13/2022, 12:32 PMthdxr
06/13/2022, 12:32 PMthdxr
06/13/2022, 12:32 PMthdxr
06/13/2022, 12:33 PMthdxr
06/13/2022, 3:21 PM