Skip to content

Commit 4bf56c2

Browse files
committed
Upgrade to Feathers v5 (dove) compatibility with TypeScript
Major changes: - Convert entire codebase from JavaScript to TypeScript - Add full Elasticsearch 8.x client compatibility - Fix all adapter-tests to achieve 100% pass rate (137/137 tests) - Add Docker setup for testing with Elasticsearch 8.15.0 - Migrate from ESLint legacy config to flat config format Key fixes: - Add missing index parameter to all ES operations (get, create, update, patch, remove) - Fix parent-child document handling with proper routing - Fix bulk operations for ES8 client response structure - Implement proper field selection in bulk patch operations - Handle undefined routing parameters correctly - Add default parameters to prevent undefined errors Infrastructure: - Add docker-compose.yml for local Elasticsearch testing - Add wait-for-elasticsearch.js script for CI/CD - Configure TypeScript with ES2018 target and CommonJS modules - Update all dependencies to stable Feathers v5 versions Breaking changes: - Requires @elastic/elasticsearch client v8.x (not v9.x) - Minimum Node.js version requirement updated - Some internal API changes for TypeScript compatibility
1 parent 92492b1 commit 4bf56c2

Some content is hidden

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

45 files changed

+9628
-4715
lines changed

.eslintignore

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

.eslintrc.js

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

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,4 @@ node_modules
3131

3232
dist/
3333
.nyc_output/
34+
lib/

TESTING.md

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# Testing feathers-elasticsearch
2+
3+
This project includes comprehensive test coverage using a real Elasticsearch instance via Docker.
4+
5+
## Prerequisites
6+
7+
- Node.js (>= 18.x)
8+
- Docker and Docker Compose
9+
- npm or yarn
10+
11+
## Running Tests
12+
13+
### Quick Test (with Docker)
14+
15+
The simplest way to run the full test suite:
16+
17+
```bash
18+
npm run docker:test
19+
```
20+
21+
This command will:
22+
1. Start Elasticsearch in Docker on port 9201
23+
2. Wait for Elasticsearch to be ready
24+
3. Run the complete test suite
25+
4. Clean up the Docker container
26+
27+
### Manual Docker Testing
28+
29+
If you want more control over the testing process:
30+
31+
```bash
32+
# Start Elasticsearch
33+
npm run docker:up
34+
35+
# Wait for it to be ready (optional, runs automatically in docker:test)
36+
npm run docker:wait
37+
38+
# Run tests against the Docker instance
39+
npm run test:integration
40+
41+
# Clean up when done
42+
npm run docker:down
43+
```
44+
45+
### Docker Management
46+
47+
- **Start Elasticsearch**: `npm run docker:up`
48+
- **Stop and clean up**: `npm run docker:down`
49+
- **View logs**: `npm run docker:logs`
50+
- **Wait for readiness**: `npm run docker:wait`
51+
52+
### Environment Variables
53+
54+
- `ES_VERSION`: Elasticsearch version to use (default: 8.15.0)
55+
- `ELASTICSEARCH_URL`: Elasticsearch connection URL (default: http://localhost:9201)
56+
57+
### Test Configuration
58+
59+
The test suite supports multiple Elasticsearch versions:
60+
- 5.0.x
61+
- 6.0.x
62+
- 7.0.x
63+
- 8.0.x (default)
64+
65+
## Test Structure
66+
67+
- `test/` - Main test files using `@feathersjs/adapter-tests`
68+
- `test-utils/` - Test utilities and schema definitions
69+
- `test-utils/schema-*.js` - Version-specific Elasticsearch schemas
70+
71+
## Coverage
72+
73+
Test coverage reports are generated with nyc and displayed after test completion.
74+
75+
```bash
76+
# Run tests with coverage
77+
npm test
78+
79+
# Run only coverage (after tests)
80+
npm run coverage
81+
```

docker-compose.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
version: '3.8'
2+
3+
services:
4+
elasticsearch:
5+
image: docker.elastic.co/elasticsearch/elasticsearch:8.15.0
6+
container_name: feathers-elasticsearch-test
7+
environment:
8+
- discovery.type=single-node
9+
- xpack.security.enabled=false
10+
- xpack.security.enrollment.enabled=false
11+
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
12+
ports:
13+
- "9201:9200"
14+
- "9301:9300"
15+
healthcheck:
16+
test: ["CMD-SHELL", "curl -f http://localhost:9200/_cluster/health || exit 1"]
17+
interval: 30s
18+
timeout: 10s
19+
retries: 5
20+
start_period: 60s
21+
volumes:
22+
- elasticsearch_data:/usr/share/elasticsearch/data
23+
24+
volumes:
25+
elasticsearch_data:
26+
driver: local

eslint.config.js

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/* eslint-env node */
2+
const js = require('@eslint/js');
3+
4+
module.exports = [
5+
{
6+
ignores: ['coverage/**', 'lib/**', 'node_modules/**', 'eslint.config.js', 'scripts/**']
7+
},
8+
js.configs.recommended,
9+
{
10+
files: ['src/**/*.js'],
11+
languageOptions: {
12+
ecmaVersion: 2022,
13+
sourceType: 'module'
14+
},
15+
rules: {
16+
semi: ['error', 'always']
17+
}
18+
},
19+
{
20+
files: ['test/**/*.js', 'test-utils/**/*.js'],
21+
languageOptions: {
22+
ecmaVersion: 2022,
23+
sourceType: 'commonjs',
24+
globals: {
25+
require: 'readonly',
26+
module: 'writable',
27+
exports: 'writable',
28+
process: 'readonly',
29+
console: 'readonly',
30+
Buffer: 'readonly',
31+
__dirname: 'readonly',
32+
__filename: 'readonly',
33+
global: 'writable'
34+
}
35+
},
36+
rules: {
37+
semi: ['error', 'always'],
38+
'no-unused-vars': ['error', { 'argsIgnorePattern': '^_' }]
39+
}
40+
},
41+
{
42+
files: ['test/**/*.js'],
43+
languageOptions: {
44+
globals: {
45+
describe: 'readonly',
46+
it: 'readonly',
47+
before: 'readonly',
48+
after: 'readonly',
49+
beforeEach: 'readonly',
50+
afterEach: 'readonly'
51+
}
52+
}
53+
}
54+
];

0 commit comments

Comments
 (0)