Skip to content

Commit 5fd10f9

Browse files
committed
Update README.md
1 parent 7095973 commit 5fd10f9

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

README.md

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# mu-javascript-template
1+
# Mu Javascript template
22

3-
Template for writing mu.semte.ch services in JavaScript
3+
Template for writing mu.semte.ch services in JavaScript using [Express 4](https://expressjs.com/)
44

55
## Getting started
66

@@ -9,7 +9,7 @@ Create a new folder. Add the following Dockerfile:
99
FROM semtech/mu-javascript-template
1010
MAINTAINER Aad Versteden <[email protected]>
1111

12-
Create your microservice:
12+
Create your microservice in `app.js`:
1313

1414
import { app, query } from 'mu';
1515

@@ -35,18 +35,22 @@ Create your microservice:
3535
res.send( "Oops something went wrong: " + JSON.stringify( err ) );
3636
});
3737
} );
38+
39+
Check [Express' Getting Started guide](https://expressjs.com/en/starter/basic-routing.html) to learn how to build a REST API in Express.
3840

3941
## Requirements
4042

41-
- **database link**: You need a link to the `database` which exposes a sparql endpoint on `http://database:8890/sparql`. In line with other microservices.
43+
- **database link**: You need a link to the `database` which exposes a SPARQL endpoint on `http://database:8890/sparql`. In line with other microservices.
4244

4345
## Imports
4446

4547
The following importable variables are available:
4648

47-
- `app`: The application on which routes can be added
49+
- `app`: The [Express application](https://expressjs.com/en/guide/routing.html) on which routes can be added
4850
- `query(query) => Promise`: Function for sending queries to the triplestore
4951
- `update(query) => Promise`: Function for sending updates to the triplestore
52+
- `uuid()` => string: Generates a random UUID
53+
- `sparql`: [Template tag](https://www.npmjs.com/package/sparql-client-2#using-the-sparql-template-tag) to create queries with interpolated values
5054

5155
You can either import specific attributes from the mu library, or import the whole mu object.
5256

@@ -66,11 +70,15 @@ An example of importing the whole library:
6670
res.send('Hello using full import');
6771
} );
6872

73+
## Dependencies
74+
75+
You can install additional dependencies by including a `package.json` file next to your `app.js`. It works as you would expect: just define the packages in the `dependencies` section of the `package.json`. They will be installed automatically at build time.
76+
6977
## Developing with the template
7078

71-
When developing, you can use the template image, mount the volume with your sources on `/app` and add a link to the database.
79+
When developing, you can use the template image, mount the volume with your sources on `/app` and add a link to the database. The service will live-reload on changes. You'll need to restart the container when you define additional dependencies in your `package.json`.
7280

73-
dr run --link virtuoso:database \
81+
docker run --link virtuoso:database \
7482
-v `pwd`:/app \
7583
-p 8888:80 \
7684
--name my-js-test \

0 commit comments

Comments
 (0)