<commit_before>// Load modules

var Joi = require('joi');
var Utils = require('./utils');


// Declare internals

var internals = {};

var relativeToRegex = /^[\/\.]/;
if (process.platform === 'win32') {
    relativeToRegex = /^([A-Za-z]:\\)|(\.)/;  //Either starts with letter followed by ":\" or starts with period.
}


// Validate server options

exports.server = function (options) {

    var error = Joi.validate(options, internals.serverSchema);
    return (error ? error.annotated() : null);
};


internals.cache = Joi.object({
    name: Joi.string().invalid('_default'),
    engine: Joi.alternatives(Joi.string(), Joi.object(), Joi.func()).required(),
    partition: Joi.string(),
    shared: Joi.boolean()
}).options({ allowUnknown: true });


internals.viewSchema = function (base) {
    var schema = {
        path: Joi.string(),
        basePath: Joi.string(),
        compileOptions: Joi.object(),
        runtimeOptions: Joi.object(),
        layout: Joi.string().allow(false, true),
        layoutKeyword: Joi.string(),
        layoutPath: Joi.string(),
        encoding: Joi.string(),
        isCached: Joi.boolean(),
        allowAbsolutePaths: Joi.boolean(),
        allowInsecureAccess: Joi.boolean(),
        partialsPath: Joi.string(),
        helpersPath: Joi.string(),
        contentType: Joi.string(),
        compileMode: Joi.string().valid('sync', 'async')
    };

    return Utils.merge(schema, base);
};


internals.serverSchema = {
    app: Joi.object().allow(null),
    cache: Joi.alternatives(Joi.string(), internals.cache, Joi.array().includes(internals.cache)).allow(null),
    cors: Joi.object({
        origin: Joi.array(),
        isOriginExposed: Joi.boolean(),
        matchOrigin: Joi.boolean(),
        maxAge: Joi.number(),
        headers: Joi.array(),
        additionalHeaders: Joi.array(),
        methods: Joi.array(),
        additionalMethods: Joi.array(),
        exposedHeaders: Joi.array(),
        additionalExposedHeaders: Joi.array(),
        credentials: Joi.boolean()
    }).allow(null, false, true),
    debug: Joi.object({
        request: Joi.array().allow(false)
    }).allow(false),
    files: Joi.object({
        relativeTo: Joi.string().regex(relativeToRegex).required(),
        etagsCacheMaxSize: Joi.number().min(0)
    }).allow(false, true),
    json: Joi.object({
        replacer: Joi.alternatives(Joi.func(), Joi.array()).allow(null),
        space: Joi.number().allow(null),
        suffix: Joi.string().allow(null)
    }),
    labels: [Joi.string(), Joi.array().includes(Joi.string())],
    load: {
        maxHeapUsedBytes: Joi.number().min(0),<commit_msg>Regex handles all path starting options (including Azure paths)<commit_after>// Load modules

var Joi = require('joi');
var Utils = require('./utils');


// Declare internals

var internals = {};

// Validate server options

exports.server = function (options) {

    var error = Joi.validate(options, internals.serverSchema);
    return (error ? error.annotated() : null);
};


internals.cache = Joi.object({
    name: Joi.string().invalid('_default'),
    engine: Joi.alternatives(Joi.string(), Joi.object(), Joi.func()).required(),
    partition: Joi.string(),
    shared: Joi.boolean()
}).options({ allowUnknown: true });


internals.viewSchema = function (base) {
    var schema = {
        path: Joi.string(),
        basePath: Joi.string(),
        compileOptions: Joi.object(),
        runtimeOptions: Joi.object(),
        layout: Joi.string().allow(false, true),
        layoutKeyword: Joi.string(),
        layoutPath: Joi.string(),
        encoding: Joi.string(),
        isCached: Joi.boolean(),
        allowAbsolutePaths: Joi.boolean(),
        allowInsecureAccess: Joi.boolean(),
        partialsPath: Joi.string(),
        helpersPath: Joi.string(),
        contentType: Joi.string(),
        compileMode: Joi.string().valid('sync', 'async')
    };

    return Utils.merge(schema, base);
};


internals.serverSchema = {
    app: Joi.object().allow(null),
    cache: Joi.alternatives(Joi.string(), internals.cache, Joi.array().includes(internals.cache)).allow(null),
    cors: Joi.object({
        origin: Joi.array(),
        isOriginExposed: Joi.boolean(),
        matchOrigin: Joi.boolean(),
        maxAge: Joi.number(),
        headers: Joi.array(),
        additionalHeaders: Joi.array(),
        methods: Joi.array(),
        additionalMethods: Joi.array(),
        exposedHeaders: Joi.array(),
        additionalExposedHeaders: Joi.array(),
        credentials: Joi.boolean()
    }).allow(null, false, true),
    debug: Joi.object({
        request: Joi.array().allow(false)
    }).allow(false),
    files: Joi.object({
        relativeTo: Joi.string().regex( /^([\/\.])|([A-Za-z]:\\)|(\\\\)/).required(),
        etagsCacheMaxSize: Joi.number().min(0)
    }).allow(false, true),
    json: Joi.object({
        replacer: Joi.alternatives(Joi.func(), Joi.array()).allow(null),
        space: Joi.number().allow(null),
        suffix: Joi.string().allow(null)
    }),
    labels: [Joi.string(), Joi.array().includes(Joi.string())],
    load: {
        maxHeapUsedBytes: Joi.number().min(0),
{'fraction_non_alphanumeric': 0.17480069998055608, 'fraction_numerical': 0.00116663426015944, 'mean_word_length': 2.9088145896656536, 'pattern_counts': {'":': 1, '<': 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': '7409555', 'n_tokens_mistral': 1624, 'n_tokens_neox': 1612, 'n_words': 313}