var downloadAndExtractTGZ = function(filepath, destDir, agentCoreFlag) {
 	if (agentCoreFlag) {
		fs.createReadStream('binaries/agentcore/tgz/'+filepath).pipe(zlib.createGunzip()).on('error', function(err) {
			console.log('ERROR: Failed to gunzip ' + filepath + ': ' + err.message);
			process.exit(1);
		})
		.pipe(tar.Extract({path: destDir})).on('error', function(err) {
			console.log('ERROR: Failed to untar ' + filepath + ': ' + err.message);
			process.exit(1);
		})
		.on('close', function() {
			console.log('Download and extract of ' + filepath + ' finished.');
		});
	} else {
		fs.createReadStream('binaries/appmetrics/tgz/'+filepath).pipe(zlib.createGunzip()).on('error', function(err) {
			console.log('ERROR: Failed to gunzip ' + filepath + ': ' + err.message);
			process.exit(1);
		})
		.pipe(tar.Extract({path: destDir})).on('error', function(err) {
			console.log('ERROR: Failed to untar ' + filepath + ': ' + err.message);
			process.exit(1);
		})
		.on('close', function() {
			console.log('Download and extract of ' + filepath + ' finished.');
		});
	}
	
};
Example #2
0
File: tar.js Project: AllenWeb/node
  fst.on("data", function OD (c) {
    // detect what it is.
    // Then, depending on that, we'll figure out whether it's
    // a single-file module, gzipped tarball, or naked tarball.
    // gzipped files all start with 1f8b08
    if (c[0] === 0x1F &&
        c[1] === 0x8B &&
        c[2] === 0x08) {
      fst
        .pipe(zlib.Unzip())
        .on("error", log.er(cb, "unzip error "+tarball))
        .pipe(tar.Extract(extractOpts))
        .on("entry", extractEntry)
        .on("error", log.er(cb, "untar error "+tarball))
        .on("close", cb)
    } else if (c.toString().match(/^package\//)) {
      // naked tar
      fst
        .pipe(tar.Extract(extractOpts))
        .on("entry", extractEntry)
        .on("error", log.er(cb, "untar error "+tarball))
        .on("close", cb)
    } else {
      // naked js file
      var jsOpts = { path: path.resolve(target, "index.js") }

      if (process.platform !== "win32" &&
          typeof uid === "number" &&
          typeof gid === "number") {
        jsOpts.uid = uid
        jsOpts.gid = gid
      }

      fst
        .pipe(fstream.Writer(jsOpts))
        .on("error", log.er(cb, "copy error "+tarball))
        .on("close", function () {
          var j = path.resolve(target, "package.json")
          readJson(j, function (er, d) {
            if (er) {
              log.error(tarball, "Not a package")
              return cb(er)
            }
            fs.writeFile(j, JSON.stringify(d) + "\n", cb)
          })
        })
    }

    // now un-hook, and re-emit the chunk
    fst.removeListener("data", OD)
    fst.emit("data", c)
  })
Example #3
0
                    rimraf(path.join(installDir, 'Contents'), function (err) { //delete old app
                        if (err) {
                            defer.reject(err);
                        } else {
                            var extractor = tar.Extract({
                                    path: installDir
                                }) //extract files from tar
                                .on('error', function (err) {
                                    defer.reject(err);
                                })
                                .on('end', function () {
                                    App.vent.trigger('notification:show', new App.Model.Notification({
                                        title: 'Update ' + this.updateData.version + ' Installed',
                                        body: this.updateData.description,
                                        showRestart: true,
                                        type: 'info'
                                    }));

                                    win.debug('Extraction success!');
                                });
                            fs.createReadStream(updateTAR)
                                .on('error', function (err) {
                                    defer.reject(err);
                                })
                                .pipe(extractor);
                        }
                    });
Example #4
0
 .once('entry', function (e) {
     if (!baseDir && e.props.path) {
         //This should be the dynamic path
         // that Github adds to the tarballs
         baseDir = e.props.path;
         log.info('extracting tar file to ' + output);
         var readTar = fs.createReadStream(tarFile);
             readTar.pipe(tar.Extract({ path: output }))
                 .on('end', function() {
                     log.info('tar file extracted');
                     var from = path.join(output, baseDir, 'src'),
                         to = path.join(output, 'src');
                     log.info('copying from ' + from);
                     log.info('copying to ' + to);
                     cpr(from, to, {
                         confirm: true
                     }, function() {
                         log.info('cleaning up..');
                         rimraf(path.join(output, baseDir), function() {
                             log.info('removing temp tar file');
                             fs.unlink(tarFile, function() {
                                 log.info('proceeding..');
                                 callback();
                             });
                         });
                     });
                 });
     }
 });
Example #5
0
  createExtractor(mirrorPath, resolve, reject) {
    const validateStream = new (_crypto || _load_crypto()).HashStream();
    const extractorStream = new (_stream || _load_stream()).UnpackStream();
    const untarStream = tar.Extract({ path: this.dest, strip: 1 });

    extractorStream.pipe(untarStream).on('error', reject).on('entry', entry => {
      if ((_constants || _load_constants()).ROOT_USER) {
        entry.props.uid = entry.uid = 0;
        entry.props.gid = entry.gid = 0;
      }
    }).on('end', () => {
      const expectHash = this.hash;
      const actualHash = validateStream.getHash();
      if (!expectHash || expectHash === actualHash) {
        resolve({
          hash: actualHash,
          resolved: mirrorPath ? `${mirrorPath}#${actualHash}` : null
        });
      } else {
        reject(new (_errors || _load_errors()).SecurityError(this.config.reporter.lang('fetchBadHash', expectHash, actualHash)));
      }
    });

    return { validateStream: validateStream, extractorStream: extractorStream };
  }
 return new Promise((resolve, reject) => {
   fs.createReadStream(sourceFile)
     .pipe(zlib.createGunzip())
     .pipe(tar.Extract(Object.assign({}, {path: destination}, tarOptions)))
     .on('error', (err) => reject(err))
     .on('end', () => resolve());
 });
Example #7
0
    r.on('response', function(resp) {

        /*!
         * no error if repository doesn't exists
         */
        /*istanbul ignore if*/
        if(resp.statusCode === 404) {
            return done();
        }

        /*istanbul ignore next*/
        if(resp.statusCode !== 200 || resp.headers['content-type'] !== 'application/octet-stream') {
            return done(new Error('unexpected statusCode (' + resp.statusCode + ' != 200) or content-type (' + resp.headers['content-type'] + ' != application/octet-stream)'));
        }

        /**
         * check if repository directory already exists and
         * clear it if yes
         */
        if(fs.existsSync(self.screenshotRoot)) {
            rimraf.sync(self.screenshotRoot);
            fs.mkdirsSync(self.screenshotRoot, '0755', true);
        }

        resp.pipe(zlib.Gunzip()).pipe(tar.Extract({ path: '.' })).on('end', done);

    });
Example #8
0
          fs.mkdirp(details.extractPath, () => {
            // wget the tgz, save as
            // ~/.tessel/binaries/MODULE-NAME.tgz
            var gunzip = zlib.createGunzip();
            var extract = tar.Extract({
              path: details.extractPath,
            });

            gunzip.on('error', function(error) {
              if (error.code === 'Z_DATA_ERROR') {
                details.resolved = false;

                // Remove extraction directory
                fs.removeSync(details.extractPath);

                resolve();
              }
            });

            request({
                url: url,
                gzip: true,
              })
              .pipe(gunzip)
              .pipe(extract)
              .on('error', reject)
              .on('end', () => {
                // Once complete, the locally cached binary can
                // be found in ~/.tessel/binaries
                resolve();
              });
          });
 var promise = new Promise(function (resolve, reject) {
   var tarExtract = tar.Extract({ type: 'Directory', path: directory, strip: 1 });
   tarExtract.on('close', resolve);
   tarExtract.on('error', reject);
   unzip.on('error', reject);
   unzip.pipe(tarExtract);
 });
	var grab = function(item) {
		console.log("Grab called on ", item);
		if (dlProcs[item.path]) {
			console.log("Grab already in progress", item);
			return null;
		};
		item.totalDown = 0;
		var remoteUrl = window.localStorage.url+'/tar?path='+encodeURIComponent(item.path)+'&sessu='+encodeURIComponent(window.localStorage.sid);
		var req = request.get(remoteUrl).pipe(tar.Extract({ path: window.localStorage.downloadLocation }));
		dlProcs[item.path] = req;
		var lastPercentage = 0;
		req.on('data', function(data) {
			item.totalDown += data.length;
			item.percentDown = (item.totalDown / item.size * 100).toFixed(2);
			$scope.$apply()
			if (item.percentDown.split('.')[0] !== lastPercentage) {
				Socket.emit('progress', {name: item.name, totalDown: item.totalDown, percentDown: item.percentDown});
				lastPercentage = item.percentDown.split('.')[0];
				console.log(lastPercentage);
			};
		});
		req.on('end', function() {
			console.log("Dl process has been ended", item);
			remove(item);
			delete dlProcs[item.path];
		});
	};
Example #11
0
  //Attempts to download a single url
  function downloadSingle(source, dest, timeout) {
    var gunzip = zlib.createGunzip();
    var tarExtract = tar.Extract({ path: dest, strip: 1 });

    var requestOptions = { url: source };
    if (timeout !== 0) {
      requestOptions.timeout = timeout;
    }

    return wrappedRequest(requestOptions)
    .then(function (req) {
      var reporter = progressReporter(logger, req);

      req
      .on('response', reporter.handleResponse)
      .on('data', reporter.handleData)
      .on('error', _.partial(reporter.handleError, 'ENOTFOUND'))
      .pipe(gunzip)
      .on('error', _.partial(reporter.handleError, 'EEXTRACT'))
      .pipe(tarExtract)
      .on('error', _.partial(reporter.handleError, 'EEXTRACT'))
      .on('end', reporter.handleEnd);

      return reporter.promise;
    });
  }
Example #12
0
 tarfile.on('finish', function() {
     shell.rm(filename);
     fs.createReadStream(tar_path)
         .pipe(tar.Extract({ path: download_dir }))
         .on("error", function (err) {
             if (callback) callback(err);
             else throw err;
         })
         .on("end", function () {
             shell.rm(tar_path);
             // move contents out of extracted dir
             var entries = fs.readdirSync(download_dir);
             var entry = path.join(download_dir, entries[0]);
             shell.mv('-f', path.join(entry, (platform=='blackberry'?'blackberry10':''), '*'), download_dir);
             shell.rm('-rf', entry);
             hooker.fire('after_library_download', {
                 platform:platform,
                 url:url,
                 id:id,
                 version:version,
                 path:download_dir,
                 size:payload_size
             }, function() {
                 if (callback) callback();
             });
         });
 });
Example #13
0
 return when.promise(function(resolve,reject) {
     fs.createReadStream(src)
         .pipe(zlib.createGunzip())
         .pipe(tar.Extract({ path: dstDir,strip:1}))
         .on('error', function(err) { reject(err);})
         .on("end", function() { resolve(); } )
 });
Example #14
0
 git.exec('archive', gitOptions, [options.branch], function (err, msg) {
   if (err) {
     // Error occurred downloading from the source
     callback && callback(err);
     return;
   }
   if (options.dest) {
     // Read in the downloaded tarfile
     fs.createReadStream(gitOptions.output)
       // Explode the downloaded tarfile
       .pipe(tar.Extract({ path: options.dest }))
       // Handle extraction errors
       .on('error', function (er) {
         callback && callback(er);
       })
       // Handle successful extraction completion
       .on('end', function () {
         // Return string containing path to downloaded tarfile.
         callback && callback(null, cleanup());
       });
   }
   else {
     // Return string containing path to downloaded tarfile.
     callback && callback(null, cleanup());
   }
 });
Example #15
0
  fs.exists(dest, function(exists){
    if(exists){
      debug('already extracted %s', tildify(dest));
      cleanup.clear();
      return fn(null, dest);
    }

    debug('reading %s', tildify(tarball));
    var input = fs.createReadStream(tarball),
      ungzip = zlib.createGunzip(),
      extractor = tar.Extract({path: dest, strip: 1});

    extractor.on('end', function(){
      debug('created %s', tildify(dest));
      cleanup.clear();
      fn(null, dest);
    });

    input.pipe(ungzip);
    ungzip.on('finished', function(){
      debug('ungzipped');
    });

    extractor.on('error', function(err){
      console.error(err);
    });

    debug('untar-ing....');
    ungzip.pipe(extractor);
  });
Example #16
0
// heavily based on npm's util/untar.js file
function fetch(tarball, target, cb) {
  var now = +new Date;

  cb = cb || function() {};

  // tarball untar opts
  var extractOpts = { type: 'Directory', path: target, strip: 1 };

  // remote request --> zlib.Unzip() --> untar into {{ target }}
  var req = request.get(tarball).on('error', cb);

  req
    // first gzip
    .pipe(zlib.Unzip())
    .on('error', cb)
    // then tar extract into h5bp/root
    .pipe(tar.Extract(extractOpts))
    .on('entry', function(entry) {
      // weirdy, todo, better handle this.
      entry.props.uid = entry.uid = 501;
      entry.props.gid = entry.gid = 20;
    })
    .on('error', cb)
    .on('close', cb);

  return req;
}
CacheDependencyManager.prototype.extractDependencies = function (cachePath, callback) {
  var self = this;
  var installDirectory = getAbsolutePath(this.config.installDirectory);
  var fileBackupDirectory = getFileBackupPath(installDirectory);
  var targetPath = path.dirname(installDirectory);
  this.cacheLogInfo('clearing installed dependencies at ' + installDirectory);
  fs.removeSync(installDirectory);
  this.cacheLogInfo('...cleared');
  this.cacheLogInfo('extracting dependencies from ' + cachePath);

  function onError(error) {
    self.cacheLogError('Error extracting ' + cachePath + ': ' + error);
    callback(error);
  }
  function onEnd() {
    if (self.config.addToArchiveAndRestore) {
      self.restoreFile(fileBackupDirectory, self.config.addToArchiveAndRestore);
      fs.removeSync(fileBackupDirectory);
    }
    self.cacheLogInfo('done extracting');
    callback();
  }

  var extractor = tar.Extract({path: targetPath})
                     .on('error', onError)
                     .on('end', onEnd);

  fs.createReadStream(cachePath)
    .on('error', onError)
    .pipe(extractor);
};
function fetch (pkg, ver, dest, callback) {
	range(pkg, ver)
		.pipe(zlib.Unzip())
		.pipe(tar.Extract({ path: dest, strip: 1 }))
		.on('error', function (err) { callback(err); })
		.on('end', function () { callback(); });
}
Example #19
0
    fs.exists(dest, function(exists){
      if(exists){
        debug('already extracted', dest);
        cleanup.clear();
        return fn(null, dest);
      }
      debug('reading ' + tarball);

      var input = fs.createReadStream(tarball),
        ungzip = zlib.createGunzip(),
        extractor = tar.Extract({path: dest, strip: 1});

      extractor.on('end', function(){
        ended = true;
        debug('created', dest, arguments);
        cleanup.clear();
        fn(null, dest);
      });

      input.pipe(ungzip);
      ungzip.on('finished', function(){
        debug('ungzipped');
      });

      debug('untar-ing....');
      ungzip.pipe(extractor);
    });
Example #20
0
 http.get(response.headers.location, function (redirectResponse) {
         var len = parseInt(redirectResponse.headers['content-length'], 10),
             bar = new ProgressBar('Downloading dynamodb-local [:bar] :percent :etas', {
                 complete: '=',
                 incomplete: ' ',
                 width: 40,
                 total: len
             });
         if (200 != redirectResponse.statusCode) {
             throw new Error('Error getting DynamoDb local latest tar.gz location ' + response.headers.location + ': ' + redirectResponse.statusCode);
         }
         redirectResponse
             .pipe(zlib.Unzip())
             .pipe(tar.Extract({
                 path: installPath
             }))
             .on('data', function (chunk) {
                 bar.tick(chunk.length);
             })
             .on('end', function () {
                 callback("\n Installation complete!");
             })
             .on('error', function (err) {
                 throw new Error("Error in downloading Dynamodb local " + err);
             });
     })
Example #21
0
        process: function process(proc, resolve, reject, done) {
          const extractor = tar.Extract({ path: dest });
          extractor.on('error', reject);
          extractor.on('end', done);

          proc.stdout.pipe(extractor);
        }
Example #22
0
 function remoteDB(remote, cb) {
   var targz = request(remote)
   var bar
   
   targz.on('response', function(r) {
     var pending = +r.headers['x-file-count']
     bar = new ProgressBar('  [:bar] :elapseds elapsed, eta :etas', {
       width: 20,
       total: pending
     })
   })
   
   var gunzip = zlib.createGunzip()
   var untarStream = tar.Extract({ path: paths.level, strip: 1 })
   var untarError = false
   
   untarStream.on('entry', function(entry) {
     if (entry.type === 'File') bar.tick()
   })
   
   untarStream.on('error', function(e) {
     untarError = true
     console.log('untar error', e)
     cb(e)
   })
   
   untarStream.on('end', function() {
     if (untarError) return
     initStorage(cb)
   })
       
   targz.pipe(gunzip).pipe(untarStream)
 }
Example #23
0
    function untarAsset(assetPath, _output) {

      const deferred = Q.defer()
      const tarPath = assetPath.replace('.tar.bz2', '.tar')

      grunt.log.writeln('Uncompressing', assetPath, 'to', tarPath)

      const compressedData = fs.readFileSync(assetPath)
      const data = Bunzip.decode(compressedData)

      fs.writeFileSync(tarPath, data)

      grunt.log.writeln('Untarring', tarPath)

      const extractor = tar.Extract({ path: _output })
        .on('error', (err) => {
          grunt.log.error(err)
          done(false)
        })
        .on('end', () => {
          deferred.resolve()
        })

      fs.createReadStream(tarPath).pipe(extractor)

      return deferred.promise
    }
Example #24
0
File: util.js Project: junmer/edp
exports.unpack = function ( tarball, target, callback ) {
    var zlib = require( 'zlib' );
    var tar = require( 'tar' );
    var fs = require( 'fs' );
    var path = require( 'path' );
    var parentDir = path.resolve( target, '..' );

    require( 'mkdirp' ).sync( parentDir );
    var tmpName = (new Date()).getTime() + Math.random();
    var tmpDir = path.resolve( parentDir, './' + tmpName );

    require( 'fstream' )
        .Reader( { 
            type: 'File',
            path: tarball
        } )
        .pipe( zlib.createGunzip() )
        .pipe( tar.Extract( { path: tmpDir } ) )
        .on(
            'end',
            function () {
                fs.renameSync( 
                    path.resolve( tmpDir, './package' ), 
                    target 
                );
                fs.rmdirSync( tmpDir );
                callback && callback();
            }
        );
};
Example #25
0
      .on('response', function(npmRes) {

        if (npmRes.statusCode != 200)
          return reject('Bad response code ' + npmRes.statusCode);

        if (npmRes.headers['content-length'] > 50000000)
          return reject('Response too large.');

        npmRes.pause();

        var gzip = zlib.createGunzip();

        npmRes
        .pipe(gzip)
        .pipe(tar.Extract({
          path: targetDir, 
          strip: 1, 
          filter: function() {
            return !this.type.match(/^.*Link$/);
          }
        }))
        .on('error', reject)
        .on('end', resolve);

        npmRes.resume();
      })
Example #26
0
function addModule(queryUrl, req, res) {
  var temp = path.join(tempDir, 't' + parseInt(Math.random() * 10000000));
  fsExt.mkdirS(temp);
  req.pipe(zlib.Unzip()).
    pipe(tar.Extract({path: temp})).
    on('error', function() {
      console.error('error----');
    }).
    on('close', function() {
      // 读取tar包信息
      // 在把tar包打包到相应的位置
      var files = fs.readdirSync(temp);

      // 获取模块临时目录.
      var tempModuleDir = path.join(temp, files[0]);

      // 获取模块部署目录.
      var modulePath = getModulePath(tempModuleDir, queryUrl);
console.log('modulePath:' + modulePath);

      if (!modulePath) {
        console.error('module read error !');
        res.end();
      } else {
        copyModule(tempModuleDir, modulePath, files[0], function() {
          // copy dist file to right dir.
          fsExt.copydirSync(path.join(modulePath, 'dist'), path.join(modulePath));
          setTimeout(function() {
            fsExt.rmdirRF(path.join(modulePath, 'dist'));
          }, 50);
          res.end();
        });
      }
    });
}
Example #27
0
app.post(config.endpoint, function(req, res) {
  if(config.key && req.get(config.keyHeader) !== config.key) {
    res.status(400).end();
    return;
  }

  var files = _.toArray(req.files);
  if(files.length < 1) {
    res.status(400).end();
    return;
  }

  var file = files[0];
  if(!/\.tar\.gz$/.test(file.originalname)) {
    res.status(400).end();
    return;
  }

  fs.createReadStream(file.path)
  .pipe(zlib.createGunzip())
  .pipe(tar.Extract({
    path: config.dest,
    strip: 0
  }))
  .on('error', function() {
    res.status(500).end(file.originalname + " unpacking failed.\n");
    fs.unlink(file.path);
  })
  .on('end', function() {
    res.end(file.originalname + "unpacked successfully.\n");
    fs.unlink(file.path);
    console.log(file.originalname + " unpacked to: " + config.dest);
  });
});
Example #28
0
  fs.exists(config.node.working, function(exists){
    if(exists){
      debug('already extracted', config.node.working);
      return fn(null, config);
    }

    debug('reading...', config.node.dest);
    input = fs.createReadStream(config.node.dest);
    ungzip = zlib.createGunzip();
    extractor = tar.Extract({path: config.cache});

    extractor.on('end', function(){
      debug('created', config.node.working);
      fn(null, config);
    });

    debug('ungzip-ing...');
    input.pipe(ungzip);
    ungzip.on('error', function(err){
      debug('error ungziping', err);
      throw err;
    }).on('finished', function(){
      debug('ungzipped');
    });

    debug('untar-ing....');
    ungzip.pipe(extractor);
  });
Example #29
0
            return new Promise(function(resolve, reject) {
                start.pipe(zlib.createGunzip())
                .on('error', function() {
                    reject(new Errors.BadRequestError('Invalid gzip'));
                })
                .pipe(tar.Extract({path: tmpDir + '/' + name}))
                .on('end', function() {
                    return self.installPack(tmpDir + '/' + name, skuid)
                        .spread(function(skuId, contents) {
                            return self.registerPack(skuId, contents)
                            .then(function() {
                                return self.regenerateSkus();
                            }).then(function() {
                                resolve({id: skuId});
                            });
                        })
                        .catch(function(e) {
                            reject(new Errors.BadRequestError(e.message));
                        })
                        .finally(function() {
                            return Promise.all([
                                rimrafAsync(tmpDir + '/' + name),
                                req.file ? fs.unlinkAsync( req.file.path ) : Promise.resolve()
                            ]);

                        });
                })
                .on('error', function() {
                    reject(new Errors.InternalServerError('Failed to serve file request'));
                });
            });
Example #30
0
PackReceiver.prototype.processTarball = function(req, res, tarGzPath, hash) {
  var self = this;

  var id = hash + '.' + Date.now();
  var untarDir = this.cicada.workdir({id: id});
  var tarOptions = {
    path: untarDir,
    strip: 1,
  };
  var readStream = fs.createReadStream(tarGzPath);
  var unzipStream = zlib.createGunzip();
  var untarStream = tar.Extract(tarOptions);

  debug('start untgz from %s', tarGzPath);
  debug('start untgz into %s', untarDir);

  // FIXME sequence below appears to not validate its input... wtf? repro by
  // using curl with --data instead of --data-binary... no errors occur. Or
  // sending a zero-byte file.

  readStream.pipe(unzipStream).pipe(untarStream);

  readStream.on('error', function(err) {
    self.sendError(res, 'Read %s failed with: %s', tarGzPath, err);
  });
  unzipStream.on('error', function(err) {
    self.sendError(res, 'Untar %s failed with: %s', tarGzPath, err);
  });
  untarStream.on('error', function(err) {
    self.sendError(res, 'Untar %s failed with: %s', tarGzPath, err);
  });

  untarStream.on('end', function() {
    debug('done untgz from %s', tarGzPath);
    debug('done untgz into %s', untarDir);

    // XXX(sam) I'm setting up a structure where I use my own folders
    // to distinguish between services... but perhaps I could find a way to
    // use repos? The last element of the git push path will be 'deploy',
    // but perhaps we can manually make the path be
    //   /api/Services/SVC/deploy/SVC
    // so that a single cicada instatnce takes care of tracking the 'repo'
    // rather than the Container needing a Cicada per service?
    var repo = 'default';

    var branch = 'npm-pack';
    var commit = cicadaCommit({
      hash: hash,
      id: id,
      dir: untarDir,
      repo: repo,
      branch: branch,
    });
    commit.runInPlace = false;
    self.cicada.emit('commit', commit);
    res.writeHead(200);
    res.end('Application received');
  });
};