Skip to content

Commit

Permalink
Updates (WIP)
Browse files Browse the repository at this point in the history
  • Loading branch information
jgoldfar committed Sep 14, 2023
1 parent 3fb913f commit 103e77a
Show file tree
Hide file tree
Showing 10 changed files with 4,623 additions and 8,809 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/node-benchmark-containerized.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,23 @@ jobs:
steps:
# https://github.com/actions/checkout
- name: Checkout the commit triggering this job
uses: actions/checkout@v2
uses: actions/checkout@v4
#
- name: Install Postgres Client
run: |
sudo apt-get update
sudo apt-get install --yes --no-install-recommends postgresql-client
#
- name: Initialize database with initdb
run: |
PGPASSWORD=password psql -h localhost -U acronymapi --dbname=defaultdb --file=initdb.sql
#
- name: Setup Node with npm cache
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}
cache: 'npm'

#
- name: Install dependencies from package.json
run: npm install

Expand Down
14 changes: 8 additions & 6 deletions .github/workflows/node-test-containerized.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test API w/ Postgres
name: Test API against Postgres Service Container

on:
push:
Expand All @@ -9,7 +9,7 @@ on:

jobs:
install-test:
name: Application Validation
name: Node application tests
strategy:
matrix:
node: ['14', '16']
Expand Down Expand Up @@ -37,22 +37,24 @@ jobs:
steps:
# https://github.com/actions/checkout
- name: Checkout the commit triggering this job
uses: actions/checkout@v2
uses: actions/checkout@v4
#
- name: Install Postgres Client
run: |
sudo apt-get update
sudo apt-get install --yes --no-install-recommends postgresql-client
#
- name: Initialize database with initdb
run: |
PGPASSWORD=password psql -h localhost -U acronymapi --dbname=defaultdb --file=initdb.sql
# https://github.com/actions/setup-node
# https://github.com/actions/cache is no longer needed with setup-node v2
- name: Setup Node with npm cache
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
cache: 'npm'

#
- name: Install dependencies from package.json
run: npm install

Expand All @@ -61,7 +63,7 @@ jobs:

- name: Run tests against live Postgres server
if: matrix.node == '16'
run: npm --test_live_pg_server=true run test
run: npm --test_live_server=true run test
env:
PGUSER: acronymapi
PGPASSWORD: password
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM node:17.6-alpine

WORKDIR /app
COPY package*.json /app/
COPY package*.json /app
RUN npm ci

RUN chown -R node:node /app
Expand Down
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Acronym API Demo

[![GitHub Actions Test Status](https://github.com/DesertFrogSolutions/AcronymApiDemo/actions/workflows/node-test-containerized.yml/badge.svg?branch=main)](https://github.com/DesertFrogSolutions/AcronymApiDemo/actions/workflows/node-test-containerized.yml)
[![Test API implementation](https://github.com/DesertFrogSolutions/AcronymApiDemo/actions/workflows/node-test-containerized.yml/badge.svg?branch=main)](https://github.com/DesertFrogSolutions/AcronymApiDemo/actions/workflows/node-test-containerized.yml)

[![Benchmark API implementations w/ Postgres Service Container](https://github.com/DesertFrogSolutions/AcronymApiDemo/actions/workflows/node-benchmark-containerized.yml/badge.svg)](https://github.com/DesertFrogSolutions/AcronymApiDemo/actions/workflows/node-benchmark-containerized.yml)

This project demonstrates an API built on Node.JS.
There are multiple implementations available in this repository using different Node.JS web server frameworks, to compare performance and ergonomics.
This is a tech demo demonstrating an API built on Node.JS in 2022, and now serves as a case study in the maintenance burden for an API built in NodeJS without significant feature work.
For the purposes of comparing performance and ergonomics, we completed multiple implementations of the same API in this repository using different Node.JS web server frameworks.

- [Node.JS HTTP Module](https://nodejs.org/docs/latest/api/http.html) (`plain`)
- [Restify](https://github.com/restify/node-restify) (`restify`)
Expand All @@ -14,6 +14,11 @@ There are multiple implementations available in this repository using different
- [Koa](https://github.com/koajs/koa) (`koa`)

> *Note* - Neither the PostgreSQL backend nor the web server implementations are configured to be production-ready.
> This program is distributed in the hope that it will be useful,
> but WITHOUT ANY WARRANTY; without even the implied warranty of
> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
For more information, reach out to the team at [[email protected]](mailto:[email protected]) or [desertfrogsolutions.com](https://desertfrogsolutions.com)

## Install & Initialize PostgreSQL DB

Expand Down Expand Up @@ -70,7 +75,7 @@ npm run dev:express

### Testing

The `spec.js` file contains functional tests in [Mocha](https://mochajs.org/) for the server with the PostgreSQL access stubbed out with [Sinon](https://sinonjs.org/). Run them all with
The `spec.js` file contains functional tests in [Mocha](https://mochajs.org/) for the server with the PostgreSQL access stubbed out with [Sinon](https://sinonjs.org/). Run them with

```sh
npm run test
Expand Down Expand Up @@ -99,7 +104,3 @@ npm --test_live_node_server=true run test:express
### Benchmarks

Benchmarks are automated using [Autocannon](https://github.com/mcollina/autocannon); with a server running in another process, run benchmarks with the command

```sh
npm run benchmark
```
Loading

0 comments on commit 103e77a

Please sign in to comment.