Skip to content

Commit e204575

Browse files
authored
feat: publish api-test-toolkit library (1.13.0) (#63)
* upgrade deps * downgrade migrate * library separation * move tests * upgrade node v24, use test docker * esm export fix * fix ci * fix pg test * fix test again * fix ci test command * update release script * build all before tests * fix release ci * chore(release): 1.13.0 [skip ci]
1 parent 922c1f9 commit e204575

66 files changed

Lines changed: 5450 additions & 8159 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.eslintrc.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,25 @@
11
module.exports = {
22
root: true,
33
extends: ['@stacks/eslint-config', 'prettier'],
4-
overrides: [],
4+
overrides: [
5+
{
6+
files: ['**/*.test.ts', '**/tests/**/*.ts'],
7+
rules: {
8+
// node:test `describe` / `it` return promises that the runner consumes; awaiting them is optional/noisy.
9+
'@typescript-eslint/no-floating-promises': 'off',
10+
// Spies and SQL tagged templates often surface as `any` in tests.
11+
'@typescript-eslint/no-unsafe-return': 'off',
12+
},
13+
},
14+
],
515
parser: '@typescript-eslint/parser',
616
parserOptions: {
717
tsconfigRootDir: __dirname,
8-
project: './tsconfig.json',
18+
project: ['./packages/api-toolkit/tsconfig.json', './packages/api-test-toolkit/tsconfig.json'],
919
ecmaVersion: 2020,
1020
sourceType: 'module',
1121
},
12-
ignorePatterns: ['*.config.js', 'bin/*.js'],
22+
ignorePatterns: ['*.config.js', '**/bin/*.js', '**/dist/**', '**/coverage/**'],
1323
plugins: ['@typescript-eslint', 'eslint-plugin-tsdoc', 'prettier'],
1424
rules: {
1525
'prettier/prettier': 'error',

.github/workflows/ci.yml

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT}
3232

3333
- name: Cache node modules
34-
uses: actions/cache@v4
34+
uses: actions/cache@v5
3535
id: npm-cache # use this to check for `cache-hit` ==> if: steps.npm-cache.outputs.cache-hit != 'true'
3636
with:
3737
path: ${{ steps.npm-cache-dir.outputs.dir }}
@@ -73,7 +73,7 @@ jobs:
7373
run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT}
7474

7575
- name: Cache node modules
76-
uses: actions/cache@v4
76+
uses: actions/cache@v5
7777
id: npm-cache # use this to check for `cache-hit` ==> if: steps.npm-cache.outputs.cache-hit != 'true'
7878
with:
7979
path: ${{ steps.npm-cache-dir.outputs.dir }}
@@ -84,25 +84,13 @@ jobs:
8484
- name: Install deps
8585
run: npm ci --audit=false
8686

87-
- name: Setup integration environment
88-
run: |
89-
sudo ufw disable
90-
npm run testenv:run -- -d
91-
npm run testenv:logs -- --no-color &> docker-compose-logs.txt &
92-
9387
- name: Run tests
94-
run: npm run test -- --coverage
88+
run: npx c8 --reporter=lcov npm run test -w @stacks/api-toolkit
9589

9690
- name: Upload coverage to Codecov
97-
uses: codecov/codecov-action@v5
98-
99-
- name: Print integration environment logs
100-
run: cat docker-compose-logs.txt
101-
if: failure()
102-
103-
- name: Teardown integration environment
104-
run: npm run testenv:stop
105-
if: always()
91+
uses: codecov/codecov-action@v6
92+
with:
93+
files: packages/api-toolkit/coverage/lcov.info
10694

10795
version:
10896
runs-on: ubuntu-latest

.github/workflows/release.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,11 @@ jobs:
3030
- name: Install deps
3131
run: npm ci --audit=false
3232

33-
- name: Publish to npm
34-
run: npm publish --provenance --access public
33+
- name: Publish @stacks/api-toolkit to npm
34+
run: npm publish --provenance --access public -w @stacks/api-toolkit
35+
36+
- name: Publish @stacks/api-test-toolkit to npm
37+
run: npm publish --provenance --access public -w @stacks/api-test-toolkit
3538

3639
github-release:
3740
runs-on: ubuntu-latest

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
node_modules
22
dist
33
.idea
4+
coverage

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
22
1+
24

README.md

Lines changed: 5 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,8 @@
1+
# API Toolkit Monorepo
12

2-
# API Toolkit
3+
Monorepo for Stacks Labs API libraries used for application runtime utilities and integration-test infrastructure.
34

4-
[![NPM Package](https://img.shields.io/npm/v/@stacks/api-toolkit.svg?style=flat-square)](https://www.npmjs.org/package/@stacks/api-toolkit)
5+
## Packages
56

6-
The API Toolkit Library is a comprehensive collection of tools designed by Stacks Labs to simplify
7-
common tasks in API development. This library provides functionalities for database management,
8-
application shutdown handlers, migration helpers, server version management, etc. It aims to
9-
streamline the development process and improve code quality by offering convenient and reusable
10-
modules.
11-
12-
## Installation
13-
14-
You can start by installing the API Toolkit Library using npm:
15-
16-
```
17-
npm install @stacks/api-toolkit
18-
```
19-
20-
You should also customize the following ENV variables that control how log messages are displayed:
21-
22-
```env
23-
APPLICATION_NAME=your-api-name
24-
LOG_LEVEL=info
25-
```
26-
27-
## Featured tools
28-
29-
Please see each tool's source directory for additional documentation
30-
31-
### Postgres
32-
33-
* Superclass for connection support and SQL transaction management using
34-
[postgres.js](https://github.com/porsager/postgres)
35-
* Connection helpers with automatic retry logic, using the standard postgres ENV variables
36-
* Migration tools for migration apply and rollback using
37-
[node-pg-migrate](https://github.com/salsita/node-pg-migrate)
38-
* Type definitions and conversion helpers for postgres to node type management and viceversa
39-
40-
### Shutdown handlers
41-
42-
* Node.js signal handlers that provide a way to shut down long-running application components
43-
gracefully on unhandled exceptions or interrupt signals.
44-
45-
### Profiler server
46-
47-
* Fastify server that controls a profiler capable of generating:
48-
* `.cpuprofile` files for CPU usage analysis
49-
* `.heapsnapshot` files for memory usage analysis
50-
51-
### Logger
52-
53-
* Standardized logger configuration using [pino](https://github.com/pinojs/pino)
54-
55-
### Server versioning
56-
57-
* `api-toolkit-git-info` executable tool to generate API versioning information based on Git branch,
58-
tag, and latest commit
59-
* Helpers to extract version info to display at runtime or on documentation
60-
61-
### Fastify
62-
63-
* API server creation with CORS, Typebox and Pino logging
64-
* OpenAPI generator plugin with YAML and JSON exports
65-
66-
### Helpers
67-
68-
* Value conversion functions (hex strings, hashes, etc.)
69-
* Timer tools (stopwatch, waiters, etc.)
70-
71-
## License
72-
73-
The API Toolkit Library is released under the Apache 2.0 License. See the LICENSE file for more
74-
details.
7+
- `@stacks/api-toolkit` (`packages/api-toolkit`): Core toolkit for API services (Postgres helpers, Fastify utilities, logging, shutdown hooks, and server version helpers).
8+
- `@stacks/api-test-toolkit` (`packages/api-test-toolkit`): Docker-based test utilities for bringing up/down service containers in automated test suites.

docker/docker-compose.dev.postgres.yml

Lines changed: 0 additions & 11 deletions
This file was deleted.

jest.config.js

Lines changed: 0 additions & 197 deletions
This file was deleted.

0 commit comments

Comments
 (0)