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
.avoid-clicks { | |
pointer-events: none; | |
} | |
/* Example: https://davidwalsh.name/demo/pointer-events.php */ |
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
sass --watch input.scss output.css |
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('/images', express.static(path.join(__dirname, path_folder_storaging_images))) | |
// Example | |
const path = require('path') | |
app.use('/images', express.static(path.join(__dirname, 'images'))) |
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
.collection('collectionName').findOne({key:value}) | |
// Example | |
const db = require('../db') | |
const ObjectId = require('mongodb').ObjectId | |
exports.getUser = ((req, res) => { | |
console.log('getUser') | |
filter = { | |
_id: new ObjectId(req.params.userId) | |
} |
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
db.collectionName.find({ key:value }) | |
// Example: | |
db.usersToSendEmail.find({_id: ObjectId("5c405972f3d33522c6242d31")}) |
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 inventory = [ | |
{name: 'apples', quantity: 2}, | |
{name: 'bananas', quantity: 0}, | |
{name: 'cherries', quantity: 5} | |
]; | |
const result = inventory.find( fruit => fruit.name === 'cherries' ); | |
console.log(result) // { name: 'cherries', quantity: 5 } |
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
// String required | |
body('name') | |
.trim() | |
.not().isEmpty() | |
.withMessage('This field is required') | |
.isString() | |
.withMessage('This field must be an string') | |
// Email required |
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
// body('name').not().isEmpty() | |
// Example | |
router.post('/insert', [ | |
body('name') | |
.trim() | |
.not().isEmpty() | |
.withMessage('This field is required'), | |
body('email') |
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
<!-- This simple form uses the novalidate attribute to turn off the browser's automatic validation; --> | |
<form novalidate> | |
<p> | |
<label for="mail"> | |
<span>Please enter an email address:</span> | |
<input type="email" id="mail" name="mail"> | |
<span class="error" aria-live="polite"></span> | |
</label> | |
</p> | |
<button>Submit</button> |
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
// In the entry file often index.js or app.js | |
const express = require('express') | |
const app = express() | |
app.use((req, res, next) => { | |
res.setHeader('Access-Control-Allow-Origin', '*') // The second parámeter could be a list of domains | |
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, PATCH, DELETE') | |
res.setHeader('Access-Control-Allow-Headers', 'Content-Type, Authorization') | |
next() |