Skip to content

Commit 175cbb7

Browse files
committed
Update README.md
1 parent c8f4575 commit 175cbb7

File tree

1 file changed

+31
-20
lines changed

1 file changed

+31
-20
lines changed

README.md

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,22 @@
1-
Export JS Template
2-
==================
1+
Export service
2+
==============
33

44
Microservice to export data using custom defined SPARQL queries.
55

66
## Using the template
7-
Run the `semtech/mu-export-js-template` service and mount an export configuration in `/config/export.js`.
7+
Extend `semtech/mu-export-service` service and add an export configuration in `/config/export.js`.
8+
9+
## Example Dockerfile
10+
11+
```
12+
FROM semtech/mu-export-service:0.3.0
13+
MAINTAINER Erika Pauwels <erika.pauwels@gmail.com>
14+
15+
COPY export.js /config/export.js
16+
17+
```
18+
19+
## Export configuration
820

921
The `export.js` file defines an array of export configuration objects as follows:
1022

@@ -27,27 +39,12 @@ An export configuration object consists of the following properties:
2739
* [REQUIRED] `query`: the SPARQL query to execute. This may be a `SELECT` or a `CONSTRUCT` query.
2840
* [OPTIONAL] `file`: name of the downloaded file. The filename may also be provided through a query param on the export request (e.g. `/example?file=my-name.csv`). If no filename is provided, the export will be displayed inline in the browser.
2941

30-
## Example docker-compose
31-
32-
```yaml
33-
version: '2',
34-
services:
35-
export:
36-
image: semtech/mu-export-js-template:0.2.0
37-
volumes:
38-
- ./:/config
39-
links:
40-
- database:database
41-
```
42-
43-
Note: if you extend the `semtech/mu-export-js-template` with an `export.js` file instead of mounting a volume in `/config`, the `ONBUILD` commands of the `semtech/mu-javascript-template` will not be executed in your image since `ONBUILD` is only executed one level deep.
44-
4542
## Using variables in the export query
4643
You can also define variables in your SPARQL export query which will be replaced with query param values at runtime. Therefore, we use [ES6's tagged template literals](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#Tagged_template_literals).
4744

48-
Import the `template` tag function from `/app/template.js` in your `export.js` and apply the tag function on your query. You can then define variables in your SPARQL query using `${'myVariable'}`. At runtime the variable will be replaced with the value provided in the `myVariable` query param of the request.
45+
Import the `template` tag function from `/app/template.js` in your `export.js` and apply the tag function on your query. You can then define variables in your SPARQL query using `${'myVariable'}` (note the quotes around the variable name). At runtime the variable will be replaced with the value provided in the `myVariable` query param of the request.
4946

50-
An example `export.js` file may look as follows:
47+
An example `export.js` including variables file may look as follows:
5148

5249
```javascript
5350
import template from '/app/template.js';
@@ -65,3 +62,17 @@ export default [
6562
```
6663

6764
A GET request on `/example?class=<http://xmlns.com/foaf/0.1/Person>` will export the first 100 URIs of type `foaf:Person`.
65+
66+
## Example docker-compose
67+
If you don't want to build a new Docker image you can also run `semtech/mu-export-service` and mount your export configuration in `/config`.
68+
69+
```yaml
70+
version: '2',
71+
services:
72+
export:
73+
image: semtech/mu-export-service:0.3.0
74+
volumes:
75+
- ./:/config
76+
links:
77+
- database:database
78+
```

0 commit comments

Comments
 (0)