Skip to content

Commit 9018102

Browse files
authored
feat(nodejs): migrate codebase to typescript, and introduce undici as transport (#42)
* refactor: migrate to typescript, introduce undici, and improve contributing * chore: update dependencies and improve Sender class functionality - Bumped versions of several devDependencies in package.json and pnpm-lock.yaml, including eslint, prettier, and testcontainers. - Enhanced the Sender class by introducing a flushPromiseChain to manage flush operations sequentially, ensuring data integrity during high load. - Refactored the HTTP request handling to improve error logging and response management. - Added new private methods for buffer management and data sending logic. - Updated tests to reflect changes in error messages and ensure proper functionality under high load conditions.
1 parent 9c88d7d commit 9018102

Some content is hidden

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

66 files changed

+12950
-14499
lines changed

.eslintrc.json

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

.github/workflows/build.yml

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,17 @@ name: build
22

33
on:
44
push:
5-
schedule:
6-
- cron: '15 2,10,18 * * *'
5+
branches:
6+
- main
7+
pull_request:
78

89
jobs:
910
test:
1011
name: Build with Node.js ${{ matrix.node-version }}
1112
runs-on: ubuntu-latest
1213
strategy:
1314
matrix:
14-
node-version: [16, latest]
15+
node-version: [20, 22, latest]
1516
steps:
1617
- name: Checkout repository
1718
uses: actions/checkout@v4
@@ -23,11 +24,16 @@ jobs:
2324
with:
2425
node-version: ${{ matrix.node-version }}
2526

26-
- name: Install dependencies
27-
run: npm ci
27+
- uses: pnpm/action-setup@v4
28+
with:
29+
version: 9
30+
run_install: true
31+
32+
- name: Linting
33+
run: pnpm eslint
2834

29-
- name: Run tests
30-
run: npm test
35+
- name: Type-checking
36+
run: pnpm typecheck
3137

32-
- name: Run linter
33-
run: npm run eslint
38+
- name: Tests
39+
run: pnpm test

.github/workflows/publish.yml

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
name: build
1+
name: publish
22

33
on:
4-
push:
5-
branches:
6-
- main
4+
workflow_dispatch:
75

86
jobs:
9-
build:
10-
name: Publish @questdb/nodejs-questdb-client to npm
7+
test:
8+
name: Publish
119
runs-on: ubuntu-latest
1210
steps:
1311
- name: Checkout repository
@@ -18,16 +16,21 @@ jobs:
1816
- name: Setup node
1917
uses: actions/setup-node@v4
2018
with:
21-
node-version: latest
19+
node-version: 22
2220

23-
- name: Install dependencies
24-
run: npm ci
21+
- uses: pnpm/action-setup@v4
22+
with:
23+
version: 9
24+
run_install: true
25+
26+
- name: Linting
27+
run: pnpm eslint
2528

26-
- name: Run tests
27-
run: npm test
29+
- name: Type-checking
30+
run: pnpm typecheck
2831

29-
- name: Run linter
30-
run: npm run eslint
32+
- name: Tests
33+
run: pnpm test
3134

3235
- name: Publish
3336
uses: JS-DevTools/npm-publish@v3

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ coverage
33
.idea
44
*.iml
55
.DS_Store
6+
certs
7+
dist

.prettierrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"tabWidth": 2,
3+
"useTabs": false
4+
}

CONTRIBUTING.md

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# Contributing to nodejs-questdb-client
2+
3+
Thank you for your interest in contributing to nodejs-questdb-client! This document provides guidelines and instructions for contributing to the project.
4+
5+
## Development Setup
6+
7+
1. Fork and clone the repository:
8+
```bash
9+
git clone https://github.com/YOUR_USERNAME/nodejs-questdb-client.git
10+
cd nodejs-questdb-client
11+
```
12+
13+
2. Install dependencies:
14+
```bash
15+
pnpm install
16+
```
17+
18+
19+
## Running Tests
20+
21+
The project uses Vitest for testing. Tests are located in the `test` directory.
22+
23+
1. Run tests in watch mode during development:
24+
```bash
25+
pnpm run test
26+
```
27+
28+
### Test Requirements
29+
30+
- Some tests use mock servers and certificates located in the `test/certs` directory
31+
32+
> You can generate the certificates by running the `generateCerts.sh` script in the `scripts` directory. The script requires two arguments: the output directory and the password for the certificates.
33+
`./scripts/generateCerts.sh . questdbPwd123`
34+
35+
36+
## Code Style and Quality
37+
38+
1. The project uses TypeScript. Make sure your code is properly typed.
39+
40+
2. Format your code using Prettier
41+
42+
3. Lint your code:
43+
```bash
44+
pnpm run lint
45+
```
46+
47+
4. Fix linting issues:
48+
```bash
49+
pnpm run lint --fix
50+
```
51+
52+
## Making Changes
53+
54+
1. Create a new branch for your changes:
55+
```bash
56+
git checkout -b feature/your-feature-name
57+
```
58+
59+
2. Make your changes and commit them with clear, descriptive commit messages:
60+
```bash
61+
git add .
62+
git commit -m "feat: add new feature"
63+
```
64+
65+
We follow the [Conventional Commits](https://www.conventionalcommits.org/) specification for commit messages.
66+
67+
3. Push your changes to your fork:
68+
```bash
69+
git push origin feature/your-feature-name
70+
```
71+
72+
4. Create a Pull Request from your fork to the main repository.
73+
74+
## Pull Request Guidelines
75+
76+
1. Make sure all tests pass
77+
2. Update documentation if needed
78+
3. Add tests for new features
79+
4. Keep PRs focused - one feature or bug fix per PR
80+
5. Link any related issues in the PR description
81+
82+
## Documentation
83+
84+
- Update the README.md if you're adding new features or changing existing ones
85+
- Add JSDoc comments for new public APIs
86+
- Include examples in the documentation when appropriate
87+
88+
## Need Help?
89+
90+
If you have questions or need help, you can:
91+
- Open an issue with your question
92+
- Join our community discussions (if available)
93+
94+
## License
95+
96+
By contributing to nodejs-questdb-client, you agree that your contributions will be licensed under the project's license.
97+

0 commit comments

Comments
 (0)