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() |
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.explain("executionStats").find() |
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 ObjectId = require('mongodb').ObjectId; | |
const id = req.params.gonderi_id; | |
const o_id = new ObjectId(id); |
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
<input onkeypress="return (event.charCode == 8 || event.charCode == 0 || event.charCode == 13) ? null : event.charCode >= 48 && event.charCode <= 57" min="0" /> |
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 x = Number("1000") |
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 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 router = express.Router() | |
router.get('/get-users', (req, res) => { | |
res.status(201).json({doc}) | |
}) |