From: Ruben Beltran del Rio Date: Sun, 19 Dec 2021 12:30:55 +0000 (+0100) Subject: Remove old binary X-Git-Url: https://git.r.bdr.sh/rbdr/generador-de-insultos/commitdiff_plain Remove old binary --- diff --git a/bin/server.js b/bin/server.js deleted file mode 100755 index 13ae381..0000000 --- a/bin/server.js +++ /dev/null @@ -1,69 +0,0 @@ -#!/usr/bin/env node - -'use strict'; - -const Fs = require('fs'); -const Path = require('path'); - -const Hapi = require('@hapi/hapi'); - -const InsultGenerator = require('../lib/InsultGenerator'); - -const replaceRe = /{{insult}}/ -let template; - - -const server = Hapi.Server({ - host: 'localhost', - port: 9200 -}); - -server.route({ - method: 'GET', - path:'/', - async handler(request, reply) { - return template.replace(replaceRe, await InsultGenerator.generate()); - } -}); - -server.route({ - config: { - cors: { - origin: ['*'], - additionalHeaders: ['cache-control', 'x-requested-with'] - } - }, - method: 'GET', - path:'/raw', - handler: function (request, reply) { - - return InsultGenerator.generate(); - } -}); - -// Preload stuff, then run -console.debug('Loading template...'); -Fs.readFile(Path.resolve(__dirname, '../ext/index.html'), {encoding: 'utf8'}, function (err, contents) { - - if (err) { - console.error(err); - process.exit(1) - } - - template = contents; - console.log('Setting up insults...') - InsultGenerator.generate() - .then(function (insult) { - - server.start(function() { - - console.debug('Server running at:', server.info.uri); - }); - }) - .catch(function (err) { - - console.error(err); - console.error('Error running insults... bad augur'); - process.exit(1); - }); -});