Skip to content

Instantly share code, notes, and snippets.

View NikhilNanjappa's full-sized avatar

Nikhil Nanjappa NikhilNanjappa

View GitHub Profile
{
"data": [
"Afghanistan",
"Akrotiri",
"Albania",
"Algeria",
"American Samoa",
"Andorra",
"Angola",
"Anguilla",
const pdfMakePrinter = require('pdfmake/src/printer');
function generatePdf(docDefinition, callback) => {
try {
const fontDescriptors = { ... };
const printer = new pdfMakePrinter(fontDescriptors);
const doc = printer.createPdfKitDocument(docDefinition);
let chunks = [];
const result;
@NikhilNanjappa
NikhilNanjappa / scan-file.js
Last active February 12, 2022 14:38
Clam AV scan-file.js
'use strict';
const NodeClam = require('clamscan');
module.exports = async function scanFile(filePath) {
console.log(`Attempting virus scan for ${filePath}`);
const clamscan = await new NodeClam().init({
remove_infected: true,
debug_mode: false,
@NikhilNanjappa
NikhilNanjappa / app.js
Last active February 12, 2022 14:27
GDS Demo partial app.js
const express = require('express')
const app = express()
const nunjucks = require('nunjucks')
const path = require('path')
nunjucks.configure([
path.join(__dirname, 'node_modules/govuk-frontend/'),
path.join(__dirname, 'app/views/')
], {
autoescape: true,
@NikhilNanjappa
NikhilNanjappa / app.js
Created February 12, 2022 14:26
GDS Demo complete app.js
const path = require('path')
const nunjucks = require('nunjucks')
const express = require('express')
const app = express()
const port = 3004
nunjucks.configure([
path.join(__dirname, 'node_modules/govuk-frontend/'),
path.join(__dirname, 'app/views/')
], {
@NikhilNanjappa
NikhilNanjappa / gulpfile.js
Created February 12, 2022 14:24
GDS Demo gulpfile.js
const gulp = require('gulp')
const sass = require('gulp-sass')
const compileStyles = () => {
return gulp.src([
'app/assets/sass/**/*.scss'
])
.pipe(sass())
.pipe(gulp.dest('public/css/'))
.on('error', (err) => {
@NikhilNanjappa
NikhilNanjappa / generatePdfStoreServer.js
Last active February 12, 2022 14:14
generatePdfStoreServer.js
const pdfMakePrinter = require('pdfmake/src/printer');
const fs = require('fs');
function generatePdf(docDefinition, successCallback, errorCallback) => {
try {
const fontDescriptors = { ... };
const printer = new pdfMakePrinter(fontDescriptors);
const doc = printer.createPdfKitDocument(docDefinition);
doc.pipe(
@NikhilNanjappa
NikhilNanjappa / generatePdfClientResponse.js
Last active February 12, 2022 14:09
generatePdfClientResponse.js
const pdfMakePrinter = require('pdfmake/src/printer');
function generatePdf(docDefinition, callback) => {
try {
const fontDescriptors = { ... };
const printer = new pdfMakePrinter(fontDescriptors);
const doc = printer.createPdfKitDocument(docDefinition);
let chunks = [];
const result;
@NikhilNanjappa
NikhilNanjappa / callGeneratePdf.js
Last active February 12, 2022 13:38
callGeneratePdf.js
const docDefinition = {
content: ['This will show up in the file created']
};
generatePdf(docDefinition, (response) => {
// doc successfully created
res.json({
status: 200,
data: response
});
@NikhilNanjappa
NikhilNanjappa / Email.js
Created February 12, 2022 13:36
Strapi email.js
await strapi.plugins['email'].services.email.send({
to: ctx.request.body.to,
from: 'your@address.com',
replyTo: 'your@address.com',
subject: 'My message',
text: 'Text',
html: '<h1>Text</h1>'
}, config);