Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Syamlal CM syamjayaraj

🎯
Focusing
View GitHub Profile
View package.json
{
"name": "express-backend",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "nodemon index.js"
},
"author": "",
"license": "ISC",
View config.js
let config = {
dbUrl:
"mongodb+srv://techomoro:password@cluster0.7cpxz.mongodb.net/posts?retryWrites=true&w=majority",
};
module.exports = config;
View posts.js
const express = require("express");
const Post = require("../models/Post");
const router = express.Router();
router.post("/", async (req, res) => {
try {
let post = new Post(req.body);
post = await post.save();
res.status(200).json({
status: 200,
View Post.js
const mongoose = require("mongoose");
let Schema = mongoose.Schema;
let postSchema = new Schema(
{
title: {
type: String,
},
description: {
type: String,
View index.js
const express = require("express");
const app = express();
const cors = require("cors");
const bodyParser = require("body-parser");
const logger = require("morgan");
const mongoose = require("mongoose");
mongoose.set("useNewUrlParser", true);
mongoose.set("useFindAndModify", false);
mongoose.set("useCreateIndex", true);
View App.js
import React, { useEffect, useState } from "react";
import AppContext from "./AppContext";
import { Grid } from "@material-ui/core";
import Header from "./components/Header";
import WordList from "./components/WordList";
import SelectDifficulty from "./components/SelectDifficulty";
import Question from "./components/Question";
import Result from "./components/Result";
View Result.jsx
import React, { useContext } from "react";
import AppContext from "../AppContext";
import { Link } from "@material-ui/core";
import { zoomInUp } from "react-animations";
import Radium, { StyleRoot } from "radium";
export default function TransitionsModal() {
const value = useContext(AppContext);
let { trueOrFalse } = value;
View Question.jsx
import React, { useContext } from "react";
import AppContext from "../AppContext";
import { makeStyles } from "@material-ui/core/styles";
import { TextField, Button } from "@material-ui/core";
const useStyles = makeStyles((theme) => ({
root: {
width: "100%",
maxWidth: 360,
View WordList.jsx
import React, { useContext } from "react";
import AppContext from "../AppContext";
import { makeStyles } from "@material-ui/core/styles";
import List from "@material-ui/core/List";
import ListItem from "@material-ui/core/ListItem";
import ListItemText from "@material-ui/core/ListItemText";
import { Divider, Typography, Button } from "@material-ui/core";
const useStyles = makeStyles((theme) => ({
root: {
View SelectDifficulty.jsx
import React, { useContext } from "react";
import AppContext from "../AppContext";
import { makeStyles } from "@material-ui/core/styles";
import List from "@material-ui/core/List";
import { ListItem, Typography } from "@material-ui/core";
import ListItemText from "@material-ui/core/ListItemText";
import Divider from "@material-ui/core/Divider";
const useStyles = makeStyles((theme) => ({
root: {