Skip to content

Feat: add get username by id api #186

Feat: add get username by id api

Feat: add get username by id api #186

Workflow file for this run

# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs
name: Node.js CI
on: [push]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [21.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
# Service containers to run with `runner-job`
services:
# Label used to access the service container
postgres:
# Docker Hub image
image: postgres
# Provide the password for postgres
env:
POSTGRES_DB: nhanify
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
# Maps tcp port 5432 on service container to the host
- 5432:5432
env:
# The hostname used to communicate with the PostgreSQL service container
POSTGRES_HOST: localhost
# The default PostgreSQL port
POSTGRES_PORT: 5432
# npm
PG_PASSWORD: postgres
PG_USER: postgres
PG_DATABASE: nhanify
# psql
PGDATABASE: nhanify
PGPASSWORD: postgres
steps:
# Downloads a copy of the code in your repository before running CI tests
- name: Check out repository code
uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: "npm"
# Performs a clean installation of all dependencies in the `package.json` file
# For more information, see https://docs.npmjs.com/cli/ci.html
- name: Install dependencies
run: npm ci
- name: Connect to PostgreSQL (make schema)
# Runs a script that creates a PostgreSQL table, populates
# the table with data, and then retrieves the data
run: psql --host=localhost --username=postgres -v ON_ERROR_STOP=1 < lib/schema.sql
- name: Connect to PostgreSQL (make seed)
run: psql --host=localhost --username=postgres -v ON_ERROR_STOP=1 < lib/seed.sql
# Environment variables used by the `client.js` script to create
# a new PostgreSQL table.
- run: npm run build --if-present
- run: npx db-migrate up --env pg
- run: npm test
- run: npx prettier . --check
- run: npx eslint .