Git Product home page Git Product logo

devops's Introduction

Contributors Forks Stargazers Issues MIT License LinkedIn


Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Roadmap
  5. Contributing
  6. License
  7. Contact
  8. Acknowledgments

About The Project

Product Name Screen Shot

to create from scratch

npx create-react-app . --use-npm
npm i gh-pages --save-dev

or install from this repo

npm i
// to edit package.json
npm init
{
  "name": "project name",
  "scripts": {
    "start": "react-scripts start",
    "deploy": "npm run build && gh-pages -d build",
    "build": "react-scripts build"
  },
  "homepage": "https://UserName.github.io/projectName"
}
// npm run build
npm run deploy


  1. This Episode on Twitch
  2. FreeCodeCamp.com Front End Projects
  3. Markdown Cheatsheet
  4. The Essential Meta Tags for Social Media
  5. GitHub Pages

GitHub Pages Deploy & Domain: TraversyMedia
https://youtu.be/SKXkC4SqtRk

  1. @ScriptHammer on Twitter
  2. LinkedIn

ScriptHammer.com
https://ScriptHammer.com

(back to top)

Built With

(back to top)

Getting Started

This is an example of how you may give instructions on setting up your project locally. To get a local copy up and running follow these simple example steps.

Prerequisites

This is an example of how to list things you need to use the software and how to install them.

  • npm
    npm install npm@latest -g

Installation

  1. Get a free API Key at https://example.com
  2. Clone the repo
    git clone https://github.com/TurtleWolfe/turtlewolfe.git
  3. Install NPM packages
    npm install
  4. Enter your API in config.js
    const API_KEY = 'ENTER YOUR API';

(back to top)

Usage

Use this space to show useful examples of how a project can be used. Additional screenshots, code examples and demos work well in this space. You may also link to more resources.

For more examples, please refer to the Documentation

(back to top)

Roadmap

  • [] Feature 1
  • [] Feature 2
  • [] Feature 3
    • [] Nested Feature

See the open issues for a full list of proposed features (and known issues).

(back to top)

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

License

Distributed under the MIT License. See LICENSE.txt for more information.

(back to top)

Contact

Your Name - @twitter_handle - dev.TurtleWolfe@gmail.co@email_client.com

Project Link: https://github.com/TurtleWolfe/turtlewolfe

(back to top)

Acknowledgments

(back to top)

devops's People

Contributors

turtlewolfe avatar

Watchers

 avatar

devops's Issues

Unhandled promise posting to API Container

link to repo
link to bug report

I've been following Lama Dev's Social Networking Tutorial
but running it in docker containers, which he doesn't do in the tutorial.
Uploading images..
I thought maybe I need to change the localhost to container name, but after moving all the images to the API and changing the folder name in the front end container that doesn't seem to be the issue.
I've also wondered if I need to be adding CORS or TLS for local development.

If the share button is just text it'll click and refresh.
As soon as I add an image, the button acts disabled.
The console log comes back with

but the screen doesn't refresh like it did with just a text and clicking 'share'
Neither are showing up on the page or in the file structure.
But Posting from PostMan does seem functional.

// import { Posts } from "../../dummyData";
import "./feed.css";
import Post from "../post/Post";
import Share from "../share/Share";
import axios from "axios";
import { AuthContext } from "../../context/AuthContext";
import { useEffect, useState, useContext } from "react";

export default function Feed({ username }) {
  const [posts, setPosts] = useState([]);
  const { user } = useContext(AuthContext);

  useEffect(() => {
    const fetchPosts = async () => {
      const res = username
        ? await axios.get("/posts/profile/" + username)
        : await axios.get("posts/timeline/" + user._id);
      setPosts(res.data);
    };
    fetchPosts();
  }, [username, user._id]);

  return (
    <div className="feed">
      <div className="feedWrapper">
        <Share />
        {posts.map((p) => (
          <Post key={p._id} post={p} />
        ))}
      </div>
    </div>
  );
}

UnHandledFeed

UnhandledHost

TaskList

  • favicon
  • ssl traefik?
  • storybook.localhost in container
  • express module in prod?
  • express module in dev?
  • multi stage story build
  • health Check depends on npm ci Jest r-frnt
  • health Check depends on node inspect mernlama
  • WARNING: No swap limit support
  • dark mode

el.type is undefined

Following LamaDev's Social Media tutorial.
Running his API and React front end in separate containers.
He connects them in the final video of the series.. so maybe I just need to mock the data?
But when I've added stories for all his components, I'm getting the same message of
el.type is undefined
so I figure it's a common error with a common denominator
any advice in the forums?

link to devOps StoryBook

link to the repo

Screenshot from 2021-09-28 12-22-51

import React from 'react';

import { CloseFriend } from './CloseFriend';

export default {
  title: 'Example/CloseFriend',
  component: CloseFriend,
};

const Template = (args) => <CloseFriend {...args} />;

export const LoggedIn = Template.bind({});
LoggedIn.args = {
  user: {},
};

export const LoggedOut = Template.bind({});
LoggedOut.args = {};

405 Not Allowed in Production

link to repo
link to bug report

I've been following Lama Dev's Social Networking Tutorial
but running it in docker containers, which he doesn't do in the tutorial. One of those containers is Traefik, which acts as a gateway for 80 and 443 and one more for an admin panel, but I haven't opened 8800 for the API because I was under the understanding that React should still see it in docker's default network, I'm not sure if the 405 is coming from the API or if that's still in React, what I've read on 405 says it's usually in the client and the line that logs the error is in React but it's in a failed call, so maybe the 405 message is an Axios response, it's saying the connection isn't allowed. I'm not sure what else to try changing?

It seems to work fine locally in Development But not in Production, It's usually up at https:geoLARP.com, if it's down for a few minutes I'm probably trying a rebuild on the server and it'll be back up shortly.

I've also wondered if I need to remove CORS, he has them in the repo but never mentions them in the video..

The only environment variable from dev to prod that I think might make a difference is LOCAL_HOST, I'm changing it to geolarp.com, should I be including the HTTP:// too?

Screenshot from 2021-10-11 13-00-14

export [email protected]
export LOCAL_HOST=localhost
export MongoDB_PASSWORD=butterzCUPz
export MongoDB_USERNAME=janeDOE
export WORDPRESS_DB_HOST=db
export WORDPRESS_DB_NAME=exampledb
export WORDPRESS_DB_PASSWORD=examplepass
export WORDPRESS_DB_USER=exampleuser
docker-compose up -d --build
docker-compose down -v --remove-orphans

I started to try through PostMan, but currently, I've not left the API open to the public, I was expecting React would see it over the docker default network by just changing the proxy to the API container. so I've changed localhost:8800 to mernlama:8800 in an .env file
Screenshot from 2021-10-11 12-20-45

Regist.jsx

import axios from "axios";
import { useRef } from "react";
import { useHistory } from "react-router";
import "./register.css";

export default function Register() {
  const username = useRef();
  const email = useRef();
  const password = useRef();
  const passwordAgain = useRef();
  const history = useHistory();

  const handleClick = async (e) => {
    e.preventDefault();
    // console.log(email.current.value);
    if (passwordAgain.current.value !== password.current.value) {
      passwordAgain.current.setCustomValidity('PassWords do not Match');
    } else {
      const user = {
        username: username.current.value,
        email: email.current.value,
        password: password.current.value,
      };
      try {
        await axios.post("/auth/register", user);
        history.push("/login");
      } catch (err) {
        console.log(err);
      }
    }
  };
  return (
    <div className="login">
      <div className="loginWrapper">
        <div className="loginLeft">
          <h3 className="loginLogo">geoLARP</h3>
          <span className="loginDesc">
            GeoLocated
          </span>
          <span className="loginDesc">
            Live Action Role Playing
          </span>
        </div>
        <div className="loginRight">
          <form className="loginBox" onSubmit={handleClick} >
            <input
              placeholder="Username"
              required
              className="loginInput"
              ref={username}
            />
            <input
              placeholder="please use a disposable Email"
              type='email'
              required
              className="loginInput"
              ref={email}
            />
            <input
              placeholder="Password"
              type='password'
              required
              minLength="6"
              className="loginInput"
              ref={password}
            />
            <input
              placeholder="Password Again"
              type='password'
              required
              className="loginInput"
              ref={passwordAgain}
            />
            <button className="loginButton" type='submit' >Sign Up</button>
            <button className="loginRegisterButton">
              Log into Account
            </button>
          </form>
        </div>
      </div>
    </div>
  );
}

expressAPI/routes/auth.js

const router = require('express').Router();
const User = require('../models/User');
const bcrypt = require('bcrypt');

// REGISTER
router.post('/register', async (req, res) => {

  try {
    // generate a salty password
    const salt = await bcrypt.genSalt(10);
    const hashedPassword = await bcrypt.hash(req.body.password, salt);

    // create a new user
    const newUser = new User({
      username: req.body.username,
      email: req.body.email,
      password: hashedPassword,
    });

    // save the user and respond
    const user = await newUser.save();
    console.log(user);
    res.status(200)
      // .json({ message: 'Registered User with API AUTH Route', user: user._id });
      .json(user);
  } catch (err) {
    res.status(500).json(err);
  }

}); // GET /api/auth


// LOGIN
router.post('/login', async (req, res) => {
  try {
    // find the user
    const user = await User.findOne({ email: req.body.email });

    // check if the user exists
    !user && res.status(404).json('User not found');


    // check if the password is correct
    const validPassword = await bcrypt.compare(req.body.password, user.password);
    !validPassword && res.status(400).json('Invalid Password');

    // respond with the user
    res.status(200).json(user);
  } catch (err) {
    res.status(500).json(err);
  }
}); // GET /api/auth/login

module.exports = router;
// export default router;

Screenshot from 2021-10-11 11-39-44
Screenshot from 2021-10-11 11-40-19

UPDATE
I've started looking at the NGINX configuration. If I understand correctly the React proxy is just for local development. So I've been looking at how Nginx Configures the Proxy Pass-Through.. These are the 2 I've tried so far, the commented out is what I tried first, but I don't have the experience with Nginx to know which settings I really need. I got Bad GateWay with the commented-out settings.

nginx.conf

server {

  listen 80;

  location / {
    root   /usr/share/nginx/html;
    index  index.html index.htm;
    try_files $uri $uri/ /index.html;
  }

  # location /api {
  #   resolver 127.0.0.11;
  #   proxy_set_header X-Forwarded-Host $host;
  #   proxy_set_header X-Forwarded-Server $host;
  #   proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  #   proxy_pass http://mernlama:8800/api;
  # }

 location /api {
   proxy_set_header X-Real-IP $remote_addr;
   proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
   proxy_set_header X-NginX-Proxy true;
   proxy_pass http://mernlama:8800/api;
   proxy_ssl_session_reuse off;
   proxy_set_header Host $http_host;
   proxy_cache_bypass $http_upgrade;
   proxy_redirect off;
 }

  error_page   500 502 503 504  /50x.html;

  location = /50x.html {
    root   /usr/share/nginx/html;
  }

}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.