<commit_before>'use strict'

const assetServiceModule = require('@darkever/assetservice')
const memdb = require('memdb');
const Joi = require('joi');

module.exports.register = function(server, options, next) {

    var assetService = new assetServiceModule(memdb());

    function addAsset(request, reply) {
        var asset = {
            name: request.query.assname,
            state: 0
        }

        assetService.addAsset(asset, function(err) {
            if (err) return reply(err);
            reply("Asset added successfully!");
        });
    }

    function modifyState(request, reply) {
        var asset = {
            name: request.query.name,
            state: request.query.state
        }

        assetService.modifyState(asset, function(err) {
            if (err) return reply(err);
            reply("Asset updated successfully!");
        });
    }

    function getState(request, reply) {
        var name = request.query.assname;

        var asset = {
            name: name
        }

        assetService.getState(asset, function(err, state) {
            if (err) return reply(err);
            console.log(state);
            reply("state: " + state);
        });
    }

    server.route({
        method: 'GET',
        path: '/asset/add',
        handler: addAsset,
        config: {
            validate: {
                query: {
                    assname: Joi.string().required().min(3).max(10).lowercase()
                }
            }
        }
    })
    server.route({
        method: 'GET',
        path: '/asset/modify',
        handler: modifyState,
        config: {
            validate: {
                query: {
                    name: Joi.string().required().min(3).max(10).lowercase(),
                    state: Joi.number().required().integer().min(0).max(2)
                }
            }
        }
    })
    server.route({ method: 'GET', path: '/asset/getState', handler: getState })

    next()
}

module.exports.register.attributes = {
    name: 'assetplugin',
    version: '1.0.0'
}<commit_msg>validazione get<commit_after>'use strict'

const assetServiceModule = require('@darkever/assetservice')
const memdb = require('memdb');
const Joi = require('joi');

module.exports.register = function(server, options, next) {

    var assetService = new assetServiceModule(memdb());

    function addAsset(request, reply) {
        var asset = {
            name: request.query.name,
            state: 0
        }

        assetService.addAsset(asset, function(err) {
            if (err) return reply(err);
            reply("Asset added successfully!");
        });
    }

    function modifyState(request, reply) {
        var asset = {
            name: request.query.name,
            state: request.query.state
        }

        assetService.modifyState(asset, function(err) {
            if (err) return reply(err);
            reply("Asset updated successfully!");
        });
    }

    function getState(request, reply) {
        var name = request.query.name;

        var asset = {
            name: name
        }

        assetService.getState(asset, function(err, state) {
            if (err) return reply(err);
            console.log(state);
            reply("state: " + state);
        });
    }

    server.route({
        method: 'GET',
        path: '/asset/add',
        handler: addAsset,
        config: {
            validate: {
                query: {
                    name: Joi.string().required().min(3).max(10).lowercase()
                }
            }
        }
    })
    server.route({
        method: 'GET',
        path: '/asset/modify',
        handler: modifyState,
        config: {
            validate: {
                query: {
                    name: Joi.string().required().min(3).max(10).lowercase(),
                    state: Joi.number().required().integer().min(0).max(2)
                }
            }
        }
    })
    server.route({ 
        method: 'GET', 
        path: '/asset/getState', 
        handler: getState,
        config: {
            validate: {
                query: {
                    name: Joi.string().required().min(3).max(10).lowercase()
                }
            }
        }    
 })

    next()
}

module.exports.register.attributes = {
    name: 'assetplugin',
    version: '1.0.0'
}
{'fraction_non_alphanumeric': 0.13477460901563937, 'fraction_numerical': 0.006209751609935602, 'mean_word_length': 1.5582352941176472, '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': '4288873', 'n_tokens_mistral': 1232, 'n_tokens_neox': 1183, 'n_words': 234}