<commit_before>'use strict';

const axios = require('axios');
const packageFile = require('./package.json');
const restify = require('restify');
var RSS = require('rss');
var fileUpload = require('express-fileupload');

async function getFeed(){
  var feed = new RSS({
    title: packageFile.name
  });

  const uris = Object.keys(packageFile.dependencies).map(async function(key) {
    return await axios.get('https://api.npms.io/v2/package/' + key);
  });

  return axios.all(uris)
    .then(function(results){

      results.forEach(function(result){
        var meta = result.data.collected.metadata
        feed.item({
          title: meta.name + ' - ' + meta.version,
          description: meta.description,
          url: 'https://api.npms.io/v2/package/' + meta.name,
          guid: meta.name + '#' + meta.version,
          date: meta.date
        })
      })
    }).then(function(){
      return feed.xml({indent: true});
    });
}

  var server = restify.createServer();
  server.use(fileUpload({
    limits: {
      fileSize: 50 * 1024,
      files: 5
    },
    safeFileNames: /package.json/
  }))

  server.post('/upload', function(req, res) {
  var sampleFile;

  if (!req.files) {
    res.send('No files were uploaded.');
    return;
  }

  // The name of the input field (i.e. "sampleFile") is used to retrieve the uploaded file
  sampleFile = req.files.sampleFile;

  // Use the mv() method to place the file somewhere on your server
  sampleFile.mv('upload/package.json', function(err) {<commit_msg>refactor - move npm parsing logic to file<commit_after>'use strict';

const axios = require('axios');
const packageFile = require('./package.json');
const restify = require('restify');
const NPMPackagesParser = require('./server/parsers/npm.js');
const npmParser = new NPMPackagesParser();
var RSS = require('rss');
var fileUpload = require('express-fileupload');

async function getFeed(){
  return await npmParser.parse('./package,json');
}

  var server = restify.createServer();
  server.use(fileUpload({
    limits: {
      fileSize: 50 * 1024,
      files: 5
    },
    safeFileNames: /package.json/
  }))

  server.post('/upload', function(req, res) {
  var sampleFile;

  if (!req.files) {
    res.send('No files were uploaded.');
    return;
  }

  // The name of the input field (i.e. "sampleFile") is used to retrieve the uploaded file
  sampleFile = req.files.sampleFile;

  // Use the mv() method to place the file somewhere on your server
  sampleFile.mv('upload/package.json', function(err) {
{'fraction_non_alphanumeric': 0.14912974683544303, 'fraction_numerical': 0.006329113924050633, 'mean_word_length': 3.1732673267326734, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 1}, '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': '28431', 'n_tokens_mistral': 810, 'n_tokens_neox': 767, 'n_words': 205}