<commit_before>const Busboy = require('busboy');
const express = require('express');
const ioUtils = require('../utils/io_utils');
const appConstants = require('../constants/app_constants');
log.warn('appConstants=' + JSON.stringify(appConstants));

const router = new express.Router();

router.get('/pdb_by_id/:pdbId', (req, res, next) => {
  if (!req.params.pdbId) {
    return next(new Error('Needs a valid pdb id.'));
  }

  // TODO fetch real pdb from some api somewhere?
  return res.send('https://s3-us-west-1.amazonaws.com/adsk-dev/3AID.pdb');
});

router.put('/upload', (req, res, next) => {
  log.trace('/upload');
  const busboy = new Busboy({
    headers: req.headers,
  });

  busboy.on('field', (fieldname, file) => {
    log.trace({api:'upload', event:'field', field:fieldname});
  });
  busboy.on('error', (error) => {
    log.error({message:'on busboy error', error:error});
    next(error);
  });
  busboy.on('file', (fieldname, file) => {
    log.trace({api:'upload', event:'file', fieldname:fieldname});
    ioUtils.streamToHashFile(file, `public/${appConstants.STRUCTURES}`).then((filename) => {
      log.trace({api:'upload', message:'streamed file to hash', filename:filename});
      res.send({
        path: `/${appConstants.STRUCTURES}/${filename}`,<commit_msg>Remove cruft<commit_after>const Busboy = require('busboy');
const express = require('express');
const ioUtils = require('../utils/io_utils');
const appConstants = require('../constants/app_constants');
log.warn('appConstants=' + JSON.stringify(appConstants));

const router = new express.Router();

router.get('/pdb_by_id/:pdbId', (req, res, next) => {
  if (!req.params.pdbId) {
    return next(new Error('Needs a valid pdb id.'));
  }

  // TODO fetch real pdb from some api somewhere?
  return res.send('https://s3-us-west-1.amazonaws.com/adsk-dev/3AID.pdb');
});

router.put('/upload', (req, res, next) => {
  const busboy = new Busboy({
    headers: req.headers,
  });

  busboy.on('field', (fieldname, file) => {
    log.trace({api:'upload', event:'field', field:fieldname});
  });
  busboy.on('error', (error) => {
    log.error({message:'on busboy error', error:error});
    next(error);
  });
  busboy.on('file', (fieldname, file) => {
    ioUtils.streamToHashFile(file, `public/${appConstants.STRUCTURES}`).then((filename) => {
      res.send({
        path: `/${appConstants.STRUCTURES}/${filename}`,
{'fraction_non_alphanumeric': 0.20558798999165973, 'fraction_numerical': 0.0025020850708924102, 'mean_word_length': 4.378923766816143, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 2, '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': '4091054', 'n_tokens_mistral': 803, 'n_tokens_neox': 812, 'n_words': 154}