Skip to content
This repository has been archived by the owner on Dec 27, 2022. It is now read-only.

Commit

Permalink
Merge branch 'release/v0.4.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
ColinMaudry committed Nov 2, 2016
2 parents bed94f7 + 1977e4c commit b04e987
Show file tree
Hide file tree
Showing 123 changed files with 63,986 additions and 17,976 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,10 @@ config/*.json
!config/default-template.json
!config/test.json
coverage
*.sh
*.swp
bin/selenium*
reports
*debug.log
lib/views/analytics.js
log
8 changes: 8 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,13 @@ node_js:
- "6"
- "5"
- "4"
env:
- CXX=g++-4.8
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-4.8
after_script:
- cat ./coverage/lcov.info | ./node_modules/.bin/coveralls --verbose
69 changes: 55 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPARQL router [0.3.0](https://github.com/ColinMaudry/sparql-router/issues?utf8=%E2%9C%93&q=is%3Aissue+milestone%3A0.3.0+)
# SPARQL router [0.4.0](https://github.com/ColinMaudry/sparql-router/issues?utf8=%E2%9C%93&q=is%3Aissue+milestone%3A0.4.0+)

#### A NodeJS/Express application to serve canned SPARQL queries to the world.
#### The NodeJS/Express application that powers [queery.link](https://queery.link) to serve canned SPARQL queries to the world.

| [master](https://github.com/ColinMaudry/sparql-router) ([**demo**](https://queery.link/api))| [develop](https://github.com/ColinMaudry/sparql-router/tree/develop) ([**demo**](https://sparql-router.herokuapp.com/api))|
| ------------- | ------------- |
Expand Down Expand Up @@ -42,12 +42,10 @@ This server application solves the issue:

**[Known issues](https://github.com/ColinMaudry/sparql-router/issues?q=is%3Aissue+is%3Aopen+label%3Abug)**

Now it's still jut a useful middleman between your RDF data and your data consumers, but the objective is to develop an open platform to share SPARQL queries on any endpoint. With [a nice UI](https://github.com/ColinMaudry/sparql-router-ui).

## Demo

- Master/stable: http://queery.link/api
- Develop/test: https://sparql-router.herokuapp.com/api
- Master/stable: https://queery.link
- Develop/test: https://sparql-router.herokuapp.com

## Requirements

Expand All @@ -68,22 +66,51 @@ SPARQL router is also available as an [NPM package](https://www.npmjs.com/packag

[On the wiki](https://github.com/ColinMaudry/sparql-router/wiki/Configuring-SPARQL-router).

### Test
Once it's configured, you must initialize the system queries and test queries:

```
npm run initialize
```

## Test

I haven't found a proper way to mock a triple store for testing purposes. I consequently use a remote triple store. That means the tests only work if the machine has Internet access.

The configuration used for the tests is stored in `config/test.json`.

To run the tests:
First, make sure, you have all the dev dependencies installed:

```bash
npm install
```

Tests rely on [mocha](http://mochajs.org/) and
[supertest](https://www.npmjs.com/package/supertest) for the API, and on [nightwatch](http://nightwatchjs.org) for the frontend.

### API

To run the API tests:

```bash
npm test
```

[Overview of the tests](test/tests.png).
[Overview of the API tests](test/tests.png).

Tests rely on [mocha](http://mochajs.org/) and
[supertest](https://www.npmjs.com/package/supertest).
### Frontend

To run the frontend tests:

```bash
# Make sure the dev dependencies are installed
npm install

# Start the server in development mode with the test configuration
NODE_ENV=test npm run dev

# Run the frontend tests
npm run test-ui
```

## Start it

Expand All @@ -94,7 +121,6 @@ npm start
```

Using `config/myconfig.json` configuration file:

```
NODE_ENV=myconfig npm start
```
Expand Down Expand Up @@ -125,7 +151,7 @@ The API documentation can be found [here](https://sparql-router.herokuapp.com/ap

The actions that are not read-only on the canned queries or the data require [basic authentication](https://en.wikipedia.org/wiki/Basic_access_authentication).

- HTTP POST to create or update a query
- HTTP PUT to create or update a query
- HTTP DELETE to delete a query

## Similar software
Expand All @@ -135,8 +161,23 @@ If SPARQL router doesn't match your requirements, you can have a look at these s
- [The Datatank](https://github.com/tdt/) (PHP5) "The DataTank is open source software, which you can use to transform any dataset into an HTTP API."
- [BASIL](https://github.com/the-open-university/basil) (Java) " BASIL is designed as middleware system that mediates between SPARQL endpoints and applications. With BASIL you can build Web APIs on top of SPARQL endpoints."

## Contact

- Email: colin@maudry.com
- Twitter: [@cmaudry](https://twitter.com/CMaudry) / [@queerylink](https://twitter.com/queerylink)


## Change log

#### 0.4.0

- User interface using Vue.js 1 and Bootstrap 3 (see https://queery.link)
- @OpenTriply's YASQE as the editor (http://yasqe.yasgui.org/)
- Table query results
- Single page application (= very fast transitions)
- Possibility to delete a query
- Requesting .rq or application/sparql-query returns the query text instead of the query results

#### 0.3.0

- An arbitrary endpoint can be passed with canned queries (upon creation or update) and with passthrough queries
Expand All @@ -145,7 +186,7 @@ If SPARQL router doesn't match your requirements, you can have a look at these s
- The default endpoint is the endpoint that is used if no endpoint is provided by the client
- Added support for ASK queries on `/api/ask`
- Started work on UI, using VueJS (just wireframes for now)
- Updated the [API documentation](http://queery.link/api) accordingly
- Updated the [API documentation](https://queery.link/api) accordingly

##### 0.2.2

Expand Down
63 changes: 48 additions & 15 deletions app.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
var FileStreamRotator = require('file-stream-rotator')
var bodyParser = require('body-parser');
var expose = require('express-expose');
var debug = require('debug')('routes');
var passport = require('passport');
var cors = require('express-cors');
var express = require('express');
var morgan = require('morgan');
var config = require('config');
var helmet = require('helmet');
var debug = require('debug')('routes');
var fs = require('fs');
var app = express();

var apiDoc = require('./lib/routes/apiDoc');
var sparql = require('./lib/routes/sparql');
var cannedQueries = require('./lib/routes/cannedQueries');

//My middlewares
var queryMetadata = require('./lib/middlewares/queryMetadata');
var cors = require('./lib/middlewares/cors');

//My functions
var functions = require('./lib/functions');

var parseJson = bodyParser.json({ extended: false });


/*
MIT License (MIT)
Expand Down Expand Up @@ -83,23 +91,38 @@ express.static.mime.define({'application/ld+json': ['jsonld']});

//Security
app.use(helmet());

app.use(cors);

//Logging
var logDirectory = __dirname + '/log'
fs.existsSync(logDirectory) || fs.mkdirSync(logDirectory)
var accessLogStream = FileStreamRotator.getStream({
date_format: 'YYYYMMDD',
filename: logDirectory + '/access-%DATE%.log',
frequency: 'weekly',
verbose: false
})
app.use(morgan(':date[iso]\t:remote-addr\t:method\t:url\t:req[accept]\t:req[content-type]\t:req[content-length]\t:response-time[0]\t:status', {stream: accessLogStream}))

//Home page
app.get('/', function(request,response) {
debug(request.url + " .get");
// response.expose('var siteRootUrl = "' + siteRootUrl + '";');
// response.render('index', { layout: false });
response.redirect(307,'/api');
var exposed = {};

exposed.config = JSON.parse(JSON.stringify(config.get('app')));
exposed.defaultEndpoint = defaultEndpointQuery;
exposed.config.user = "*****";
exposed.config.password = "*****";
exposed.config.port = request.socket.localPort;

response.expose(exposed);
response.expose('var siteRootUrl = "' + siteRootUrl + '";');
response.expose('var userIp = "' + request.ip + '";');
response.render('index', { layout: false,userIp: request.ip, analytics: config.get("app.public.analytics") });
});

app.use(function(req, res, next) {
//CORS support
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");

//Set app root directory
req.appRoot = __dirname;

next();
app.options('*',function(request,response){
response.sendStatus(200)
});

app.param('type', function (req, res, next, type) {
Expand All @@ -108,10 +131,20 @@ app.param('type', function (req, res, next, type) {
next();
});

app.use(function(request,response,next) {
//Set app root directory
request.appRoot = __dirname;
next();
});

app.use('/api', apiDoc);
app.use(parseJson);
app.use(queryMetadata);
app.use('/api/:type(tables|graphs|ask|update)', cannedQueries);
app.use('/api/:sparql(sparql|query)', sparql);
app.use(express.static('public'));

//Error management
app.use(function(err, req, res, next) {
debug(req.url + " Mayday!")
console.error(err.stack);
Expand Down
1 change: 1 addition & 0 deletions art/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
You can see these images on queery.link's Twitter account: [@queerylink](https://twitter.com/queerylink).
Binary file added art/square_logo.xcf
Binary file not shown.
Binary file added art/twitter_banner.xcf
Binary file not shown.
Binary file added bin/chromedriver
Binary file not shown.
6 changes: 3 additions & 3 deletions bin/www
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ app.listen(port,function() {
console.log(
'Listening on port ' + port + "\n"
+ 'Configuration: /config/' + usedConfig + ".json, which sets:\n\n"
+ "Authentication enabled........" + config.get('app.authentication') + "\n"
+ "Endpoint host (system)........." + config.get('endpoints.system.hostname') + "\n"
+ "Authentication enabled.........." + config.get('app.authentication') + "\n"
+ "Endpoint host (system).........." + config.get('endpoints.system.hostname') + "\n"
+ "Endpoint host (default)........." + config.get('endpoints.default.hostname') + "\n"
+ "Public app host:..............." + config.get('app.public.hostname') + "\n"
+ "Public app host:................" + config.get('app.public.hostname') + "\n"
);

});
75 changes: 39 additions & 36 deletions config/default-template.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,41 +38,44 @@
"port": 3000,
"public": {
"scheme": "https",
"hostname": "sparql-router.heroku.com",
"port": ""
"hostname": "sparql-router.herokuapp.com",
"port": "",
"analytics": false
},
"maxQueryLength": 4000
},



"typeByExtension": {
"tables": {
"csv": "text/csv",
"json": "application/sparql-results+json",
"srj": "application/sparql-results+json",
"srx": "application/sparql-results+xml",
"xml": "application/sparql-results+xml"
},
"graphs": {
"xml": "application/rdf+xml",
"rdf": "application/rdf+xml",
"ttl": "text/turtle",
"jsonld": "application/ld+json",
"nt": "application/n-triples",
"json": "application/ld+json"
},
"ask": {
"xml": "application/sparql-results+xml",
"srx": "application/sparql-results+xml",
"json": "application/sparql-results+json",
"srj": "application/sparql-results+json",
"csv": "text/csv"
},
"update": {
"json": "application/json",
"txt": "text/plain"
}

}
"maxQueryLength": 4000,
"typeByExtension": {
"tables": {
"csv": "text/csv",
"json": "application/sparql-results+json",
"srj": "application/sparql-results+json",
"srx": "application/sparql-results+xml",
"xml": "application/sparql-results+xml",
"rq": "application/sparql-query"
},
"graphs": {
"xml": "application/rdf+xml",
"rdf": "application/rdf+xml",
"ttl": "text/turtle",
"jsonld": "application/ld+json",
"nt": "application/n-triples",
"json": "application/ld+json",
"trig": "application/trig",
"trix": "application/trix",
"rq": "application/sparql-query"
},
"ask": {
"xml": "application/sparql-results+xml",
"srx": "application/sparql-results+xml",
"json": "application/sparql-results+json",
"srj": "application/sparql-results+json",
"csv": "text/csv",
"rq": "application/sparql-query"
},
"update": {
"json": "application/json",
"txt": "text/plain",
"rq": "application/sparql-query"
}
}
}
}

0 comments on commit b04e987

Please sign in to comment.