Skip to content

Commit 19ad042

Browse files
committed
Initial commit.
1 parent 71780d1 commit 19ad042

File tree

4 files changed

+53
-0
lines changed

4 files changed

+53
-0
lines changed

config.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"ingestArea": "/Users/stephan/Downloads/danrw/ingest"
3+
}

index.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
var express = require('express'),
2+
app = express(),
3+
oaisHandler = require('./lib/oaisHandler');
4+
5+
app.get('/', function (req, res) {
6+
res.send('Hello World!');
7+
});
8+
9+
app.post('/api/v1/ingest', oaisHandler.handleIngest);
10+
11+
var server = app.listen(3000, function () {
12+
var host = server.address().address;
13+
var port = server.address().port;
14+
15+
console.log('Example app listening at http://%s:%s', host, port);
16+
17+
});

lib/oaisHandler.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
var fs = require('fs'),
2+
path = require('path'),
3+
config = require('../config.json');
4+
5+
exports.handleIngest = handleIngest;
6+
7+
function handleIngest(req, res) {
8+
var filename = path.basename(req.params.filename),
9+
dst = fs.createWriteStream(config.ingestArea + '/' + filename);
10+
11+
req.pipe(dst);
12+
req.on('end', function() {
13+
res.sendStatus(200);
14+
});
15+
}

package.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "da-nrw-rest-api",
3+
"version": "0.0.1",
4+
"description": "A RESTful API to a DA-NRW (Digitales Archiv - Nordrhein-Westfalen) instance. The API intends to be conforming to the OAIS (Open Archival Information System) workflow.",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"keywords": [
10+
"oais",
11+
"da-nrw",
12+
"api"
13+
],
14+
"author": "Stephan Uhle",
15+
"dependencies": {
16+
"express": "^4.10.0"
17+
}
18+
}

0 commit comments

Comments
 (0)