Skip to content

Commit

Permalink
Minor readability tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
textbook committed Feb 1, 2024
1 parent 12bc96a commit fce5fdb
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions api/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
8 changes: 3 additions & 5 deletions api/server.js
Original file line number Diff line number Diff line change
@@ -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}`));
6 changes: 3 additions & 3 deletions api/setupTests.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { connect, disconnect } from "./db.js";
import { connectDb, disconnectDb } from "./db.js";

beforeAll(() => connect());
beforeAll(() => connectDb());

afterAll(() => disconnect());
afterAll(() => disconnectDb());

0 comments on commit fce5fdb

Please sign in to comment.