An example application to demonstrate how to use Neon Local.
There are two different .env.example
files. One for Development, and one for Production. Be sure to rename them correctly. NEON_API_KEY
, NEON_PROJECT_ID
and PORT
will likely be the same in both files.
Rename .env.dev.example
to .env.dev
and add required values. This environment will create an ephemeral branch when the container is started.
NODE_ENV=dev
NEON_API_KEY=
NEON_PROJECT_ID=
PORT=3000
Rename .env.prod.example
to .env.prod
and add required values. This environment connects to the database as defined by: DATABASE_URL
.
DATABASE_URL=
NODE_ENV=prod
NEON_API_KEY=
NEON_PROJECT_ID=
PORT=3000
npm install
Depending on which environment you want to use will determine which docker compose command you run.
docker compose --profile dev --env-file .env.dev up --watch
docker compose --profile prod --env-file .env.prod up --build
Visit: http://localhost:8080/ to view the app running.
Do not run the following command directly:
npm run dev
Running npm run dev
is only intended to be used by Docker.
If you need to kill all containers and images, run the following command:
bash kill.sh
The default route /
, will display the current Postgres version of the database defined by the NEON_PROJECT_ID
.
To change the query, edit the following file: src/function.js
This repository uses the Neon serverless driver. The configuration is set up in src/db.js
. While you can switch to using the pg
driver, please note that the setup will be slightly different. For more information, refer to the Neon Local docs.