Code Monkey home page Code Monkey logo

home-cloud's Introduction

Home Cloud

Host your own cloud at home

Table of Contents

Development Setup

First, clone the repo and cd into the project:

git clone https://github.com/antoniosarosi/home-cloud.git
cd home-cloud

Local setup (Linux & Windows)

Install dependencies:

cd server
npm i
cd ../client # ..\client on Windows
npm i
cd ..

Run locally

Backend

Move to the server directory:

cd server

Open sample.env and copy its content into a new file named .env, then set the correct value for HOME_CLOUD_STORAGE. Now start the server:

npm run dev

Frontend

Move to the client directory:

cd client

Open sample.env and copy its content into a new file named .env, then set the correct value for REACT_APP_API_URL. Finally, start the development server:

npm start

Backend will be running on port 5000 and frontend on port 3000 (if not already in use).

Docker (Linux)

First, set the correct value for HOME_CLOUD_STORAGE env variable:

export HOME_CLOUD_STORAGE="/home/user/example"

Then create a .env file in ./client/ and set this value:

REACT_APP_API_URL="http://localhost:8081"

Install dependencies:

docker-compose run express npm i
docker-compose run react npm i

Run on Docker containers

docker-compose up

Backend will be running on port 8081 and frontend on port 8080 (if not already in use).

Production Setup

Local (Linux & Windows)

Backend

Move to ./server/ and set the correct value for HOME_CLOUD_STORAGE in .env (see examples in sample.env), and then run npm start:

npm start

Frontend

Move to ./client/ and create a file named .env.production, set the correct value for REACT_APP_API_URL (see examples in sample.env). Then, install serve globaly:

npm i -g serve

Build the app:

npm run build # Or yarn build

Start the server:

serve -s build -l 3000 # Or another port of your choice

Docker (Linux)

First, set the correct value for HOME_CLOUD_STORAGE env variable:

export HOME_CLOUD_STORAGE="/home/user/example"

Then create a .env.production file in ./client/ and set the correct value for the API URL (your IP address and port 8081):

REACT_APP_API_URL="http://192.168.1.2:8081"

Build images and run containers:

docker-compose -f docker-compose.yml -f docker-compose.prod.yml up

home-cloud's People

Contributors

antoniosarosi avatar ca-santiago avatar dependabot[bot] avatar hhbaker avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

home-cloud's Issues

TypeError: content is undefined

imagen
imagen
imagen

Hola, cuando inicio todo me da ese error puede ser algo que tenga desactualizado?

mi version de nodejs es la: 14.17.1 y instale todo correctamente
estoy usando Windows 11 pero en Windows 10 tambien me mostraba lo mismo

Error when trying to enter a directory that has a "-" in its name

Storage Path:

/home/xxxx/home_cloud

Directory Path with error:

/home/xxxx/home_cloud/test-01-02

Error in console:

express_1 | [Error: File or directory does not exist] { from /usr/src/app/client/public
express_1 | errno: -2,
express_1 | code: 'ENOENT',
express_1 | syscall: 'opendir',
express_1 | path: '/usr/src/app/storage/test/01/02',
express_1 | statusCode: 400
express_1 | }

Tengo un bug cuando pongo npm run dev

image
Como pueden ver cuando npm run dev, se queda en server running on port 5000 y no me deja seguir poniendo nada, soy principiante, alguien me ayuda?
Ya cambie el path y todo y eso si funciona.

Refactor

Refactor a componentes funcionales

Como idea propongo hacer un refactor a componentes funcionales, yo podria hacer un pull request de eso en unos dias, ya que estoy algo ocupado.
La razon es que deja tus componentes mucho mas limpios y reutilizables.

Dejo un ejemplo de lo que me refiero, chequen mi forma de crear codigo en componentes funcionales: ejemplo

Deploy to the cloud

Use Google Cloud to upload the backend and use firebase to upload the frontend.
All of this is free.
:)

Refactor React components to hooks

Refactor class based components to look like this one:

const FormModal = (props) => {
  const [show, setShow] = useState(false);

  const handleClose = () => setShow(false);
  const handleShow = () => setShow(true);
  // ...
}

Login

Sería buena idea añadir algún tipo de login para poder trabajar de manera segura con los archivos y evitar acceso de terceros

Conexión externa

Se que es una nube en casa pero y si te pudieras conectar con la ip publica del pc desde otro lugar para guardar tus archivos desde por ejemplo el trabajo.

Problema con metodo isDirectory()

Buenas Antonio, me llamo Fabrizio.
Actualmente me encuentro aplicando ingeniería inversa a tu código con el mero propósito de aprender de él y de adquirir un panorama mas amplio.

Estoy teniendo problemas en el archivo content.js. Ubicado en: /server/src/routes/content.js.

Basicamente el problema consiste con que la consola constantemente arroja el error "isDirectory() is not a function.". Todo esto sin modificar tu código obviamente. Tuve que "arreglarlo" (con alambres como decimos en Argentina) de la siguiente forma:

router.get("/:path?", async (req, res, next) => {
  try {
    const dirPath = processPath(req.params.path);
    const dir = await fs.promises.readdir(dirPath.absolutePath);
    const content = {files: [], directories: []}
    const extensions = [
      ".rar",
      ".png",
      ".jpeg",
      ".jpg",
      ".mp3",
      ".mp4",
      ".wav",
      ".wmv",
      ".zip",
      ".json",
      ".py",
      ".java",
      ".ogg",
      ".html",
      ".docx",
      ".pdf",
      ".odb",
      ".yml",
      ".git",
      ".md",
      ".txt",
      ".js"
    ];

    for await (const dirent of dir) {
     const strlen = dirent.length;

     const extension = dirent.substring(strlen, strlen -4);
     const extension2 = dirent.substring(strlen, strlen -3);
     const extension3 = dirent.substring(strlen, strlen -5);

     // I think it is inefficient
     // Check why Sarosi's method not working
     // CHECKME:

     if (extensions.includes(extension)) {
       content.files.push(dirent);
     } else if(extensions.includes(extension2)) {
       content.files.push(dirent);
     } else if (extensions.includes(extension3)){
       content.files.push(dirent);
     } else {
       content.directories.push(dirent);
     }
    }
    content.directories.sort();
    content.files.sort();

    res.json({path: dirPath.relativePath, content, success: true});
  }
  catch(e) {
    next(e)
  }
});
module.exports = router;

La razón por la cual no abro un pull request es porque de verdad me encantaría poder adquirir una explicación de porqué no funciona bien tu código y porque es obvio que el mio es un arreglo provisorio mientras encuentro explicaciones y no una mejoría al tuyo.
Espero tus respuestas porque se que estas ocupadísimo con la universidad. Espero no molestar.

PD: Me cuesta bastante el codigo asincrónico, así que cualquier ayuda es muy muy bienvenida.

Problema

Hola a todos, alguien me podría ayudar, al ejecutar el frontend me salta el siguiente error:

TypeError: Cannot read property 'directories' of undefined
home-cloud/client/src/components/Dir.js:58

Dir.fillEntries

58*| content.directories.forEach((dir) =>
59 | directories.push()
60 | );

Supongo que sera una tontería pero es que no tengo mucha idea y voy un poco perdido

Problema al iniciar el windows

¡Hola! no sé si es el sitio adecuado para ponerlo o no, pero lo pongo.
Tengo un problema, y es que cuando inicio el backend me sale este error "Storage path not defined, set a value for HOME_CLOUD_STORAGE environment variable
[nodemon] app crashed - waiting for file changes before starting...".

En mi carpeta (Foto de mi carpeta , tengo dos archivos: sample.env y HOME_CLOUD_STORAGE.env, los dos con el mismo contenido: HOME_CLOUD_STORAGE="C:\Users\danie\Desktop\app\home-cloud\server\storage"

No me inicia, ¿una ayudita?
Gracias.

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.