Skip to content

Commit

Permalink
adds: documentation updates and code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
raygervais committed Feb 20, 2021
1 parent c3b74da commit 3eb9587
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/api/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ _Note: For this directory to have a better understanding of context, copy `env.e
| API | Docker Tag | URL | Description |
| --------------------- | --------------------------------------------- | ------------------------ | -------------------------------------------- |
| Image Service | telescope_img_svc | image.docker.localhost | Provides a dynamic image processing service |
| Search Service | telescope_search_svc | search.docker.localhost | Provides a ELK query controller service |
| Kibana Service | docker.elastic.co/kibana/kibana | kibana.docker.localhost | Provides data exploration and visualizations |
| ElasticSearch Service | docker.elastic.co/elasticsearch/elasticsearch | elastic.docker.localhost | Provides data aggregation and search |

Expand Down
37 changes: 37 additions & 0 deletions src/api/search/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Search Service

The Search Service provides a direct querying controller which interfaces with our ELK stack.

## Install

```
npm install
```

## Usage

```
# normal mode
npm start
```

By default the server is running on http://localhost:4445/.

### Examples

- `GET /query?text=Telescope&filter=post&page=0` - Returns the search results of posts containing the keyword "Telescope"
- `GET /query?text=SenecaCDOT?filter=author&page=0` - Returns the search results of authors which relate to the keyword "SenecaCDOT"
- `GET /healthcheck` - returns `{ "status": "ok" }` if everything is running properly

## Docker / Docker-Compose

### Docker

- To build and tag: `docker build . -t telescope_search_svc:latest`
- To run locally: `docker run -p 4445:4445 telescope_search_svc:latest`

### Docker-Compose

_Commands to be run from the `~/src/api` directory_

- To build and run: `docker-compose -f docker-compose-api-production.yml up --build search`
2 changes: 0 additions & 2 deletions src/api/search/server.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
const { Satellite } = require('@senecacdot/satellite');

// const health = require('./src/routes/health');
const query = require('./src/routes/query');

const service = new Satellite();
// service.router.use('/health', health);
service.router.use('/query', query);

const port = parseInt(process.env.SEARCH_PORT || 4445, 10);
Expand Down
1 change: 0 additions & 1 deletion src/api/search/src/bin/elastic.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ const ElasticConstructor = useMockElastic ? MockClient : Client;
function createElasticClient() {
try {
const elasticUrl = ELASTICSEARCH_HOSTS;
console.log(elasticUrl);
return new ElasticConstructor({ node: elasticUrl });
} catch (error) {
const message = `Unable to parse elastic URL:PORT "${ELASTICSEARCH_HOSTS}"`;
Expand Down
6 changes: 6 additions & 0 deletions src/backend/lib/elastic.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
* NOTE: This has been ported to ~/src/api/search
* Future updates will remove the codebase below
* and point towards `service.docker.localhost` for querying.
*/

const { ELASTIC_URL, ELASTIC_PORT } = process.env;
const { Client } = require('@elastic/elasticsearch');
const Mock = require('@elastic/elasticsearch-mock');
Expand Down

0 comments on commit 3eb9587

Please sign in to comment.