<commit_before>/*
 Quick and dirty server for mocking Blockstack Core REST API on localhost.
 Uses blockstack-cli for data
 Usage:
 node mockBlockstackCoreApi.js <port>
*/

var express = require('express')
var app = express(),
    port = process.argv[2] || 8889

const blockstack = process.argv[3] || "./blockstack-venv/bin/python2.7 ./blockstack-venv/bin/blockstack";
const exec = require('child_process').exec


app.get('/names/:name', function (req, res) {
    blockstackLookup(req.params.name).then((profile) => {
      res.json(JSON.parse(profile))
    }).catch((error) => {
      res.status(404)
      res.json({ 'error': 'Not found' })
    })
})

app.get('/addresses/:address/names', function (req, res) {
    blockstackGetNamesOwnedByAddress(req.params.address).then((names) => {
      res.json(JSON.parse(names))
    })<commit_msg>add CORS header to mock server<commit_after>/*
 Quick and dirty server for mocking Blockstack Core REST API on localhost.
 Uses blockstack-cli for data
 Usage:
 node mockBlockstackCoreApi.js <port>
*/

var express = require('express')
var cors = cors = require('cors')

var app = express(),
    port = process.argv[2] || 8889

const blockstack = process.argv[3] || "./blockstack-venv/bin/python2.7 ./blockstack-venv/bin/blockstack";
const exec = require('child_process').exec

app.use(cors())

app.get('/names/:name', function (req, res) {
    blockstackLookup(req.params.name).then((profile) => {
      res.json(JSON.parse(profile))
    }).catch((error) => {
      res.status(404)
      res.json({ 'error': 'Not found' })
    })
})

app.get('/addresses/:address/names', function (req, res) {
    blockstackGetNamesOwnedByAddress(req.params.address).then((names) => {
      res.json(JSON.parse(names))
    })
{'fraction_non_alphanumeric': 0.16762013729977115, 'fraction_numerical': 0.012585812356979404, 'mean_word_length': 3.899159663865546, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '2338727', 'n_tokens_mistral': 585, 'n_tokens_neox': 569, 'n_words': 122}