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/9f2e9aa1d0287a79064de90e9a6dfdc771758a62?ds=inline;hp=73d2a4923358fd9774b18a458669697cfb0b958e 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); - }); -});