O Uploadimg foi um pequeno projeto para teste de upload de imagens que usa MongoDb e Node.js para salvar os dados em banco de dados e em disco utilizando o Multer.
-
Crie um banco de dados no MongoDb Atlas;
-
Faça o download deste repositório através do botão verde Code no topo da página e, em seguida, clicando em Download ZIP. Ou, se preferir, através do terminal (Git Bash, Powershell, etc.), use o comando:
git clone https://github.com/sucodelarangela/uploadimg.git
-
Acesse a pasta do projeto com seu terminal;
-
Rode o comando
npm install
ouyarn install
para instalar as dependências (você precisa ter o Node.js instalado); -
Renomeie o arquivo
.env.example
para apenas.env
. Neste arquivo, substitua os valores das variáveis pela porta de sua preferência para olocalhost
, além do nome de usuário e senha do seu banco de dados do MongoDb Atlas criado no passo 1.
A aplicação só funcionará com esses dados corretamente inseridos no arquivo
.env
.
- Após a correta configuração acima, rode a aplicação com o comando
npm start
ouyarn start
. Você deve receber a seguinte mensagem de confirmação:
[nodemon] starting `node ./app.js`
Server running on port <porta>
Database successfully connected!
- Para simular as rotas no lado do cliente, você pode usar a extensão Thunder Client para o VS Code.
GET:
http://localhost:${port}/pictures
POST:
http://localhost:${port}/pictures
DELETE:
http://localhost:${port}/pictures/:id
English version
Uploadimg is a small project for testing image uploads using MongoDb and Node.js to save data in a database and locally using Multer.
-
Create a database in MongoDb Atlas;
-
Download this repository by clicking the green Code button on top of the page and then clicking Download ZIP option. Or use the following command on your terminal (Git Bash, Powershell, etc.):
git clone https://github.com/sucodelarangela/uploadimg.git
-
Access the project root folder on your terminal;
-
Run
npm install
oryarn install
to install all project dependencies (you must have Node.js installed); -
Rename the
.env.example
file to only.env
. In this file, replace the values for the variables with your favorite localhost port, the user name and password for the MongoDb Atlas database created on step 1.
The app will only work properly if these data are correctly set in
.env
file.
- To start the application, run
npm start
oryarn start
on yout terminal. You should receive the following message:
[nodemon] starting `node ./app.js`
Server running on port <porta>
Database successfully connected!
- To simulate the routes on client side, you can use the VS Code extension Thunder Client.
GET:
http://localhost:${port}/pictures
POST:
http://localhost:${port}/pictures
DELETE:
http://localhost:${port}/pictures/:id
Developed with 🧡 by @sucodelarangela