<commit_before>var restify = require('restify')
var server = restify.createServer()
var fs = require('fs')

const  uuid = () => 
  (+new Date() + Math.floor(Math.random() * 999999)).toString(36)

var questionnaires = JSON.parse(
    fs.readFileSync(__dirname + '/questionnaires.json', 'utf8'))

var repo = JSON.parse(
    fs.readFileSync(__dirname + '/repo.json', 'utf8'))

// var published = JSON.parse(
//     fs.readFileSync(__dirname + '/published.json', 'utf8'))
var published = {}

// allow  cross origin request
/*
MLHttpRequest cannot load http://localhost:4000/questionnaires.
No 'Access-Control-Allow-Origin' header is present on the requested resource.
Origin 'http://localhost:8080' is therefore not allowed access.
*/
restify.CORS.ALLOW_HEADERS.push('authorization');
restify.CORS.ALLOW_HEADERS.push('Location');
server.use(restify.CORS())
server.use(restify.bodyParser())


//TODO `pogues-swagger.yaml` does not say exacty which type of object is 
//returned (it's not just an object with two keys `id` and `questionnaire`<commit_msg>Add `Location` header to CORS config<commit_after>var restify = require('restify')
var server = restify.createServer()
var fs = require('fs')

const  uuid = () => 
  (+new Date() + Math.floor(Math.random() * 999999)).toString(36)

var questionnaires = JSON.parse(
    fs.readFileSync(__dirname + '/questionnaires.json', 'utf8'))

var repo = JSON.parse(
    fs.readFileSync(__dirname + '/repo.json', 'utf8'))

// var published = JSON.parse(
//     fs.readFileSync(__dirname + '/published.json', 'utf8'))
var published = {}

// allow  cross origin request
/*
MLHttpRequest cannot load http://localhost:4000/questionnaires.
No 'Access-Control-Allow-Origin' header is present on the requested resource.
Origin 'http://localhost:8080' is therefore not allowed access.
*/
restify.CORS.ALLOW_HEADERS.push('authorization');
restify.CORS.ALLOW_HEADERS.push('Location');
server.use(restify.CORS({
  headers: ['Location']   
}))
server.use(restify.bodyParser())


//TODO `pogues-swagger.yaml` does not say exacty which type of object is 
//returned (it's not just an object with two keys `id` and `questionnaire`
{'fraction_non_alphanumeric': 0.15030246626337831, 'fraction_numerical': 0.017682643089809214, 'mean_word_length': 4.6878306878306875, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1425637', 'n_tokens_mistral': 705, 'n_tokens_neox': 672, 'n_words': 180}