This file contains 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
callBackendAPI = async () => { | |
const response = await fetch('/express_backend'); | |
const body = await response.json(); | |
if (response.status !== 200) { | |
throw Error(body.message) | |
} | |
return body; | |
}; |
This file contains 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
class UserAPI(MethodView): | |
""" | |
User Resource | |
""" | |
def get(self): | |
# get the auth token | |
auth_header = request.headers.get('Authorization') | |
if auth_header: | |
auth_token = auth_header.split(" ")[1] | |
else: |
This file contains 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
Venue.aggregate([ | |
{ "$match": { "_id": mongoose.Types.ObjectId(id.id) } }, | |
{ "$lookup": { | |
"from": Review.collection.name, | |
"let": { "reviews": "$reviews" }, | |
"pipeline": [ | |
{ "$match": { "$expr": { "$in": [ "$_id", "$$reviews" ] } } }, | |
{ "$lookup": { | |
"from": Comment.collection.name, | |
"let": { "comments": "$comments" }, |
This file contains 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
from pydantic import BaseModel, Field | |
from pymongo import MongoClient | |
from bson import ObjectId | |
from typing import Optional | |
client = MongoClient() | |
db = client.test | |
class PyObjectId(ObjectId): |
This file contains 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 dotenv from 'dotenv'; | |
import { MongoClient } from 'mongodb'; | |
dotenv.config(); | |
const client = new MongoClient( | |
process.env.MONGODB_URI, | |
{ | |
useUnifiedTopology: true, | |
}, |
This file contains 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, { useState, useEffect } from "react"; | |
import axios from "axios"; | |
const App = () => { | |
const [username, setUsername] = useState(""); | |
const [password, setPassword] = useState(""); | |
const [user, setUser] = useState(); | |
useEffect(() => { | |
const loggedInUser = localStorage.getItem("user"); |
This file contains 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
location / { | |
proxy_pass http://localhost:8080; | |
proxy_http_version 1.1; | |
proxy_set_header Upgrade $http_upgrade; | |
proxy_set_header Connection 'upgrade'; | |
proxy_set_header Host $host; | |
proxy_cache_bypass $http_upgrade; | |
} | |
} |
This file contains 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; | |
const userSchema = new Schema({ | |
username: { | |
type: String, | |
index: true, | |
unique: true, | |
dropDups: true, | |
required: true, |
This file contains 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
FROM nginx | |
COPY html /usr/share/nginx/html | |
COPY nginx/default.conf /etc/nginx/conf.d/default.conf |
This file contains 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 bcrypt = require('bcryptjs'); | |
const SALT_WORK_FACTOR = 10; | |
const schema = mongoose.Schema({ | |
name: String, | |
email: String, | |
password: String, | |
active: {type: Boolean, default: false}, | |
}, {collection: 'user'}); |
NewerOlder