This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var storage = multer.diskStorage({ | |
| destination: function (req, file, callback) { | |
| callback(null, path.join(__dirname, '/tmp')); | |
| }, | |
| filename: function (req, file, callback) { | |
| callback(null, 'file-' + Date.now() + path.extname(file.originalname)); | |
| } | |
| }); | |
| var uploadFunc = multer({ storage: storage }).single('uploaded_file'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const express = require('express'); | |
| const app = express(); | |
| const port = 8080; | |
| app.use('/', express.static('public')); | |
| app.listen(port, () => console.log(`Running aserver listing on port ${port}...`)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const InfoButtonHoc = (component) => { | |
| return class ExtendedComponent extends React.Component { | |
| render() { | |
| const { tooltip, excludeTooltipProps } = this.props; | |
| return (<div className='info-btn' tooltip={tooltip}> | |
| <component {...this.excludeTooltipProps} /> | |
| </div>); | |
| } | |
| }; | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| app.use(helmet.referrerPolicy({ policy: 'same-origin' })); | |
| app.use(helmet.contentSecurityPolicy({ | |
| directives: { | |
| defaultSrc: ["'self'", ...], | |
| fontSrc: ["'self'", ...], | |
| imgSrc: ["'self'", ...], | |
| scriptSrc: ["'self'", ...], | |
| styleSrc: ["'self'", ...], | |
| connectSrc: ["'self'", ...], | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const express = require('express') | |
| const helmet = require('helmet') | |
| const app = express() | |
| app.use(helmet()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import ReCAPTCHA from "react-google-recaptcha"; | |
| function onChange(value) { | |
| console.log("Captcha value:", value); | |
| } | |
| ReactDOM.render( | |
| <ReCAPTCHA | |
| sitekey="Your client site key" | |
| onChange={onChange} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const captchaToken = req.body.token; | |
| const data = querystring.stringify({ | |
| secret: fullConfig.CAPTCHA_SECRET, | |
| response: captchaToken | |
| }); | |
| const verifiedHuman = await (new Promise((resolve, reject) => { | |
| const options = { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <html> | |
| <head> | |
| <title>reCAPTCHA demo: Simple page</title> | |
| <script src="https://www.google.com/recaptcha/api.js" async defer></script> | |
| </head> | |
| <body> | |
| <form action="?" method="POST"> | |
| <div class="g-recaptcha" data-sitekey="your_site_key"></div> | |
| <br/> | |
| <input type="submit" value="Submit"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <html> | |
| <head> | |
| <title>reCAPTCHA demo: Explicit render after an onload callback</title> | |
| <script type="text/javascript"> | |
| var onloadCallback = function() { | |
| grecaptcha.render('html_element', { | |
| 'sitekey' : 'your_site_key' | |
| }); | |
| }; | |
| </script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const nodemailer = require("nodemailer"); | |
| let transporter = nodemailer.createTransport({ | |
| service: 'Gmail', | |
| auth: { | |
| type: 'OAuth2', | |
| user: '[your email]', | |
| clientId: '', | |
| clientSecret: '', | |
| refreshToken: '', |