<commit_before>require "api/base"
require "sass"
require "compass"
require "faraday"

Compass.sass_engine_options[:load_paths].each do |path|
  Sass.load_paths << path
end

module Api
  class SendTheStyle < Base
    # global configuration elements
    configure do
      ::Compass.add_project_configuration("config/compass.rb")
    end

    ## handle 404 errors
    not_found do
      halt_404_not_found
    end

    ##
    # Homepage request; generates simple welcome message
    #
    # GET /
    #
    get "/?" do
      json({ message: "Welcome to Send-The-Styles!" })
    end

    ##
    # Create namespace to group all API methods
    #
    namespace "/api", auth_via: :valid_key? do

      ##
      # Invalid request for API namespace alone
      #
      # GET /api(/)
      #
      get "/?" do
        halt_400_bad_request
      end

      ##
      # Compile passed SASS into CSS, respecting any passed options
      #
      # GET /api/compile?file=FQDN(&option=value)
      #
      get "/compile/?" do
        # attempt to download the remote SASS file for processing
        halt_400_bad_request("Invalid SASS file") \
          unless !params[:file].nil?
        style_file = params[:file]
        halt_400_bad_request("Invalid SASS file") \
          unless !params[:file].nil?<commit_msg>Drop connections to API endpoints if not made over SSL when in production environment<commit_after>require "api/base"
require "sass"
require "compass"
require "faraday"

Compass.sass_engine_options[:load_paths].each do |path|
  Sass.load_paths << path
end

module Api
  class SendTheStyle < Base
    # global configuration elements
    configure do
      ::Compass.add_project_configuration("config/compass.rb")
    end

    ## handle 404 errors
    not_found do
      halt_404_not_found
    end

    ##
    # Homepage request; generates simple welcome message
    #
    # GET /
    #
    get "/?" do
      json({ message: "Welcome to Send-The-Styles!" })
    end

    ##
    # Create namespace to group all API methods
    #
    namespace "/api", auth_via: :valid_key? do

      ##
      # Drop the request completely if not made over SSL
      #
      before do
        if settings.environment == :production and !request.secure?
          halt
        end
      end

      ##
      # Invalid request for API namespace alone
      #
      # GET /api(/)
      #
      get "/?" do
        halt_400_bad_request
      end

      ##
      # Compile passed SASS into CSS, respecting any passed options
      #
      # GET /api/compile?file=FQDN(&option=value)
      #
      get "/compile/?" do
        # attempt to download the remote SASS file for processing
        halt_400_bad_request("Invalid SASS file") \
          unless !params[:file].nil?
        style_file = params[:file]
        halt_400_bad_request("Invalid SASS file") \
          unless !params[:file].nil?
{'fraction_non_alphanumeric': 0.09379358437935843, 'fraction_numerical': 0.010460251046025104, 'mean_word_length': 2.245475113122172, 'pattern_counts': {'":': 0, '<': 9, '<?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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5679171', 'n_tokens_mistral': 866, 'n_tokens_neox': 829, 'n_words': 245}