tenant_id
column? By specifying this column, You are making the table tenant aware. The rows in it will belong to specific tenants. If you leave it out, the table is considered shared, more on this later.
.env.example
to .env
, and update it with the connection string you just copied from Nile Console. Make sure you don’t include the word “psql”. It should look something like this:
serverless.yml
and changing the region
property.
And if you haven’t yet, install the Serverless Framework: npm install -g serverless
curl
to explore the APIs. Here are a few examples:
serverless.yml
file to the root of the project. This file contains the configuration for the Serverless Framework.serverless-http
NodeJS module, which wraps an Express app with a Serverless handler.
Using it is very straightforward:
serverless-http
wrapping above is almost enough to get the application running on AWS Lambda.
However, we need to make sure the database connection is initialized before the handler is called and remains intact between handler executions.
We are initializing the connection in the db.js
file, and exporting the connection object.
serverless.yml
fileserverless.yml
file contains the configuration for the Serverless Framework and it has 4 important sections.
The first is the general configuration. We set the name of the service, the framework version, and most important - the use of .env
file for environment variables.
us-west-2
and include the database connection string in the environment.
The region is important - you want to run your serverless application in the same region as your database. In this case - us-west-2
.
serverless-esbuild
plugin.