<commit_before>var KoaNeo4jApp = require('koa-neo4j');

console.log(KoaNeo4jApp);

var app = new KoaNeo4jApp({
    apis: [
        {
            method: 'GET',
            route: '/articles/:skip/:limit',
            cypherQueryFile: './cypher/articles.cyp'
        },
        {
            method: 'POST',
            route: '/articles',
            cypherQueryFile: './cypher/articles.cyp'
        }
    ],
    neo4j: {
        boltUrl: 'bolt://localhost',
        user: 'neo4j',
        password: 'k'
    }
});


// You can use `app.defineAPI` for better code organisation
// Perform post-processing on values return by the cypher query via `postProcess`

app.defineAPI({
    method: 'GET',
    route: '/articles/processed',
    cypherQueryFile: './cypher/articles.cyp',
    postProcess: function (result) {
        // Perform postprocessing on 'result' returned by executing the cypher query
        result.push({extra:'record'});
        // ...
        return result;
    }
});


// Routes can be guarded by role restriction using `allowedRoles`

app.configureAuthentication({
    userCypherQueryFile: './cypher/user.cyp',
        rolesCypherQueryFile: './cypher/roles.cyp',
        route: '/auth',
        secret: 'secret'
});

app.defineAPI({
    method: 'POST',
    route: '/articles/restricted',
    preProcess: function (params) {
        // Perform postprocessing on 'result' returned by executing the cypher query
        params.extra = 'extra parameter!';
        // ...
        return params;
    },
    cypherQueryFile: './cypher/articles.cyp',
    allowedRoles: ['admin']
});


// `app.router` is a standard koa-router which could be utilised to expand server's functionality
// visit github.com/alexmingoia/koa-router FMI

app.router.get('/noncypher', function (ctx, next) {
    ctx.body = "Using router you can do other things that don't need Cypher!";
    return next();
});

app.listen(3001, function () {<commit_msg>more comments<commit_after>var KoaNeo4jApp = require('koa-neo4j');

console.log(KoaNeo4jApp);

var app = new KoaNeo4jApp({
    apis: [
        {
            method: 'GET',
            route: '/articles/:skip/:limit',
            cypherQueryFile: './cypher/articles.cyp'
        },
        {
            method: 'POST',
            route: '/articles',
            cypherQueryFile: './cypher/articles.cyp'
        }
    ],
    neo4j: {
        boltUrl: 'bolt://localhost',
        user: 'neo4j',
        password: 'k'
    }
});


// You can use `app.defineAPI` for better code organisation
// Perform post-processing on values return by the cypher query via `postProcess` lifecycle hook

app.defineAPI({
    method: 'GET',
    route: '/articles/processed',
    cypherQueryFile: './cypher/articles.cyp',
    postProcess: function (result) {
        // Perform postprocessing on 'result' returned by executing the cypher query
        result.push({extra:'record'});
        // ...
        return result;
    }
});

// Authentication and roles can be configured either by
// supplying an `authentication` key in config or by `app.configureAuthentication
// Routes can be guarded by role restriction using `allowedRoles`
// Another lifecycle hook is `postProcess` which is demonstrated below

app.configureAuthentication({
    userCypherQueryFile: './cypher/user.cyp',
    rolesCypherQueryFile: './cypher/roles.cyp',
    route: '/auth',
    secret: 'secret'
});

app.defineAPI({
    method: 'POST',
    route: '/articles/restricted',
    preProcess: function (params) {
        // Perform prrprocessing on 'params' which will be given to the cypher query
        params.extra = 'extra parameter!';
        // ...
        return params;
    },
    cypherQueryFile: './cypher/articles.cyp',
    allowedRoles: ['admin']
});


// `app.router` is a standard koa-router which could be utilised to expand server's functionality
// visit github.com/alexmingoia/koa-router FMI

app.router.get('/noncypher', function (ctx, next) {
    ctx.body = "Using router you can do other things that don't need Cypher!";
    return next();
});

app.listen(3001, function () {
{'fraction_non_alphanumeric': 0.13414932680538555, 'fraction_numerical': 0.004895960832313341, 'mean_word_length': 2.5254529767040554, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1001283', 'n_tokens_mistral': 1303, 'n_tokens_neox': 1227, 'n_words': 333}