diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 4f47caf1..789dc5e7 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -63,11 +63,11 @@ jobs: tags: textbook/starter-kit:v2 - id: env-file run: | - echo "file=$ENV_FILE" >> "$GITHUB_OUTPUT" echo 'DATABASE_URL=postgres://testdb:keepitsecret@localhost:5432/testdb' >> "$ENV_FILE" echo 'LOG_LEVEL=debug' >> "$ENV_FILE" echo 'PORT=4321' >> "$ENV_FILE" echo 'NODE_ENV=docker' >> "$ENV_FILE" + echo "file=$ENV_FILE" >> "$GITHUB_OUTPUT" env: ENV_FILE: docker.env - id: docker-run diff --git a/api/db.js b/api/db.js index a38b597a..623bb4b8 100644 --- a/api/db.js +++ b/api/db.js @@ -20,13 +20,13 @@ const pool = new pg.Pool({ pool.on("error", (err) => logger.error("%O", err)); -export const connect = async () => { +export const connectDb = async () => { const client = await pool.connect(); logger.info("connected to %s", client.database); client.release(); }; -export const disconnect = async () => await pool.end(); +export const disconnectDb = async () => await pool.end(); export default { query(...args) { diff --git a/api/server.js b/api/server.js index 77d5362e..83f5ccb7 100644 --- a/api/server.js +++ b/api/server.js @@ -1,12 +1,10 @@ import app from "./app.js"; -import { connect } from "./db.js"; +import { connectDb } from "./db.js"; import config from "./utils/config.js"; import logger from "./utils/logger.js"; const { port } = config; -await connect(); +await connectDb(); -const server = app.listen(port); - -server.on("listening", () => logger.info(`listening on ${port}`)); +app.listen(port, () => logger.info(`listening on ${port}`)); diff --git a/api/setupTests.js b/api/setupTests.js index 70a7274e..f0de6d42 100644 --- a/api/setupTests.js +++ b/api/setupTests.js @@ -1,5 +1,5 @@ -import { connect, disconnect } from "./db.js"; +import { connectDb, disconnectDb } from "./db.js"; -beforeAll(() => connect()); +beforeAll(() => connectDb()); -afterAll(() => disconnect()); +afterAll(() => disconnectDb());