if (id.match(/^[0-9a-fA-F]{24}$/)) {
// Yes, it's a valid ObjectId, proceed with `findById` call.
}
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 mongoose = require("mongoose"); | |
| const Schema = mongoose.Schema; | |
| // Create Schema | |
| const PostSchema = new Schema({ | |
| user: { | |
| type: Schema.Types.ObjectId, | |
| ref: "users", | |
| }, | |
| text: { |
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
| { | |
| "useTabs": false, // Indent lines with tabs instead of spaces. | |
| "printWidth": 80, // Specify the length of line that the printer will wrap on. | |
| "tabWidth": 2, // Specify the number of spaces per indentation-level. | |
| "singleQuote": false, // Use single quotes instead of double quotes. | |
| /** | |
| * Print trailing commas wherever possible. | |
| * Valid options: | |
| * - "none" - no trailing commas | |
| * - "es5" - trailing commas where valid in ES5 (objects, arrays, etc) |
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 React from "react"; | |
| import styled, { keyframes } from "styled-components"; | |
| const slide = keyframes` | |
| from { | |
| transform: translateY(0); | |
| } | |
| to { | |
| transform: translateY(5px); |
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 React from "react"; | |
| import { graphql } from "gatsby"; | |
| import Img from "gatsby-image"; | |
| function photos({ data }) { | |
| console.log(data.images.nodes); | |
| return ( | |
| <div> | |
| <h1>All My Photos</h1> |
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
| 1,Donnamarie,Jemison,djemison0@ifeng.com,Female | |
| 2,Herculie,Chadbourne,hchadbourne1@opensource.org,Male | |
| 3,Shepperd,Luquet,sluquet2@so-net.ne.jp,Male | |
| 4,Sinclare,Nuttey,snuttey3@tmall.com,Male | |
| 5,Deane,Crimp,dcrimp4@paginegialle.it,Female | |
| 6,Cayla,Solman,csolman5@abc.net.au,Female | |
| 7,Mose,Magnar,mmagnar6@360.cn,Male | |
| 8,Wilfrid,Robertet,wrobertet7@ted.com,Male | |
| 9,Carney,Bantick,cbantick8@techcrunch.com,Male | |
| 10,Angelique,Marklund,amarklund9@engadget.com,Female |
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
| module.exports = { | |
| theme: { | |
| extend: {}, | |
| screens: { | |
| xl: { max: "1279px" }, | |
| // => @media (max-width: 1279px) { ... } | |
| lg: { max: "1023px" }, | |
| // => @media (max-width: 1023px) { ... } |
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
| MONGO_PROD_URI=mongodb+srv://admin:<password>@cluster.mongodb.net/<dbname>?retryWrites=true&w=majority | |
| MONGO_DEV_URI=mongodb://127.0.0.1:27017/<dbname> |
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 origin = | |
| process.env.NODE_ENV === "production" | |
| ? process.env.FRONTEND_PROD_URL | |
| : process.env.FRONTEND_LOCAL_URL; | |
| app.use((req, res, next) => { | |
| res.header("Access-Control-Allow-Origin", origin); | |
| res.header("Access-Control-Allow-Credentials", true); | |
| if (req.method === "OPTIONS") { |