-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
44 lines (37 loc) · 1.37 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
require('dotenv').config();
const express = require('express')
const cron = require('node-cron');
const mapper = require('./src/index');
const fs = require('fs');
const path = require('path');
const app = express()
const dir = "./public";
cron.schedule('*/10 * * * *', function() {
if(!fs.existsSync(dir)){
try{
fs.mkdirSync(dir);
}catch(err){
console.error("Error while creating folder %s", dir);
}
}
mapper();
});
app.use(function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*"); // update to match the domain you will make the request from
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
// res.header('Link', '<https://stijnbrysbaert.github.io/OSLO-extension/example_data/donkey_context.json>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"');
next();
});
var options = {
index: './bluebike.ttl',
}
var velo_options = {
setHeaders: function(res, path, stat){
res.set('Link', '<https://json-ld.org/contexts/person.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"');
}
}
app.use(express.static(path.join(__dirname, 'public'), options))
// app.use(express.static(path.join(__dirname, 'public/velo.json')))
app.listen(process.env.PORT, () => {
console.log(`Example app listening at http://localhost:${process.env.PORT}`)
})