Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

My CV

Texode Company

Monkey Company.
SARL
ENSIBS HQ
+44 45 56 78 89
18 rue du APE

Lastname
var express = require(’express’);
var app = express();
var port = 4444;
var http = require(’http’);
process.env.PWD = process.cwd()
var fs = require(’fs’);
var htmlspecialchars = require(’htmlspecialchars’);
const path = require(’path’)
const stream = require(’stream’)

var auth = require(’http-auth’);


const authConnect = require(’http-auth-connect’);

var basic = auth.basic({


realm: "Moderator Place Only ! "},
function (username, password, callback) {
callback(username === "ModAPEMONKEY" && password === "Best_P4ssw0rD_f0r_b3st_S3cUr1tY");
});

const _ = require(’lodash’);

app.get(’/modo’, authConnect(basic));

app.get(’/latex’, function(req, res, err) {


const latex = require(’node-latex’)
const input = fs.createReadStream(’input.tex’)
fs.writeFile(’/tmp/lastname.tex’, req.query.lastname, {
encoding: ’utf8’

1
}, function(err, result) {
if (err) console.log(’error’, err);
});
fs.writeFile(’/tmp/firstname.tex’, req.query.firstname, {
encoding: ’utf8’
}, function(err, result) {
if (err) console.log(’error’, err);
});
fs.writeFile(’/tmp/age.tex’, req.query.age, {
encoding: ’utf8’
}, function(err, result) {
if (err) console.log(’error’, err);
});
fs.writeFile(’/tmp/situation.tex’, req.query.situation, {
encoding: ’utf8’
}, function(err, result) {
if (err) console.log(’error’, err);
});
fs.writeFile(’/tmp/skills.tex’, req.query.skills, {
encoding: ’utf8’
}, function(err, result) {
if (err) console.log(’error’, err);
});
fs.writeFile(’/tmp/motivation.tex’, req.query.motivation, {
encoding: ’utf8’
}, function(err, result) {
if (err) console.log(’error’, err);
});

// Generate a random 6 digit


function generateRandomString(length) {
var text = "";
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
for (var i = 0; i < length; i++)
text += possible.charAt(Math.floor(Math.random() * possible.length));
return text;
}
random = generateRandomString(15);

const output = fs.createWriteStream(’./mycv/’ + random + ".pdf")


const pdf = latex(input)
const pdfData = [];
const captureStream = new stream.Writable({
write(chunk, encoding, callback) {
pdfData.push(chunk);
callback();
},
});

pdf.pipe(captureStream);

pdf.on(’finish’, () => {

2
console.log(’[+] Generated pdf : ’ + random + ".pdf");

res.setHeader(’Content-Disposition’, ‘attachment; filename=${random}.pdf‘);


res.setHeader(’Content-Type’, ’application/pdf’);

res.end(Buffer.concat(pdfData));
});

});

app.get(’/mycv’, function sleep(req, res) {


if (req.session.pdfuuid) {
res.sendFile(
path.join(__dirname, "/mycv/" + random + ".pdf")
);
} else {
res.redirect("/");
}
});

app.get

app.get(’/’, function(req, res) {


app.use(express.static(process.env.PWD + ’/img’));
fs.readFile(__dirname + ’/public/index.html’, {
encoding: ’utf8’
}, (err, text) => {
res.send(text);
});
});

app.listen(port, function() {
console.log(’http://localhost:’ + port);
});

Firstname
Age
Situation
Skills
Motivation

You might also like