Skip to content

Commit cd72f18

Browse files
authored
Merge pull request #14 from hppanpaliya/refactor-react
Refactor react & mailserver
2 parents d8d80f5 + b4746b8 commit cd72f18

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+3500
-864
lines changed

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ COPY . /React-TrashMail
2929

3030
WORKDIR /React-TrashMail/react
3131
RUN yarn build
32-
RUN rm -rf ../mailserver/build/* && mkdir -p ../mailserver/build && cp -r build/* ../mailserver/build/
32+
RUN rm -rf ../mailserver/src/build/* && mkdir -p ../mailserver/src/build/ && cp -r build/* ../mailserver/src/build/
3333

3434
# Define mountable volume
35-
VOLUME ["/React-TrashMail/mailserver/attachments"]
35+
VOLUME ["/React-TrashMail/mailserver/src/attachments"]
3636

3737
# Copy startup script
3838
COPY docker_start.sh /docker_start.sh

Dockerfile.prod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ COPY mailserver/node_modules /React-TrashMail/mailserver/node_modules
2222
COPY . /React-TrashMail
2323

2424
# Copy built React app to mailserver build directory
25-
COPY react/build /React-TrashMail/mailserver/build
25+
COPY react/build /React-TrashMail/mailserver/src/build
2626

2727
# Define mountable volume
28-
VOLUME ["/React-TrashMail/mailserver/attachments"]
28+
VOLUME ["/React-TrashMail/mailserver/src/attachments"]
2929

3030
# Copy startup script
3131
COPY docker_start.sh /docker_start.sh

README.md

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
TrashMail is a web application for generating disposable/temporary email addresses and viewing emails sent to those addresses. The project consists of a React frontend and a Node.js and MongoDB backend mail server.
44

55
## Table of Contents
6+
67
- [Frontend](#frontend)
78
- [Backend](#backend)
89
- [Deployment](#deployment)
@@ -15,6 +16,7 @@ TrashMail is a web application for generating disposable/temporary email address
1516
The React frontend provides the user interface for generating disposable emails, viewing the inbox, and reading emails.
1617

1718
### Features
19+
1820
- Generate a random disposable email address
1921
- Enter a custom disposable email address
2022
- View all received emails for an address
@@ -23,17 +25,20 @@ The React frontend provides the user interface for generating disposable emails,
2325
- Responsive design
2426

2527
### Tech Stack
28+
2629
- React
2730
- React Router
2831
- Material UI
2932
- Axios
3033

3134
### Pages
35+
3236
- **Home**: Explains the service and contains buttons to generate or enter an email
3337
- **Inbox**: Lists received emails for an address
3438
- **Email**: Displays the content of a specific email
3539

3640
### Installation
41+
3742
```shell
3843

3944
cd react
@@ -42,39 +47,44 @@ npm install
4247
```
4348

4449
### Running
50+
4551
```shell
4652

4753
npm start
4854

4955
```
56+
5057
The frontend will run on [http://localhost:3000](http://localhost:3000)
5158

5259
## Backend
5360

5461
The Node.js backend provides the mail server functionality for receiving emails via SMTP and managing emails via a REST API.
5562

5663
### Features
64+
5765
- SMTP server to receive emails
5866
- Save emails and attachments to MongoDB database
5967
- Retrieve emails for an address
6068
- Delete emails
6169
- Serve attachment files
6270

6371
### Tech Stack
72+
6473
- Node.js
6574
- Express
6675
- MongoDB
6776
- SMTP Server
6877
- Mailparser
6978

7079
### API Endpoints
71-
- `GET /emails/:emailId` - Get emails for an address
80+
7281
- `GET /emails-list/:emailId` - Get email list
7382
- `GET /all-emails` - Get all emails
7483
- `GET /email/:emailId/:email_id` - Get specific email
7584
- `DELETE /email/:emailId/:email_id` - Delete email
7685

7786
### Installation
87+
7888
```shell
7989

8090
cd server
@@ -83,14 +93,17 @@ npm install
8393
```
8494

8595
### Configuration
96+
8697
Edit `config.js` to configure SMTP port, MongoDB URL, etc.
8798

8899
### Running
100+
89101
```shell
90102

91103
node server.js
92104

93105
```
106+
94107
The backend will run on port 4000
95108

96109
## Deployment
@@ -103,17 +116,20 @@ For those who prefer a containerized deployment, Docker can be used to easily se
103116

104117
#### Docker Setup
105118

106-
1. **Build the Docker Image**:
119+
1. **Build the Docker Image**:
107120
Ensure you are in the root directory of the project and run:
121+
108122
```shell
109123
docker build -t trashmail-app .
110124
```
111125

112126
2. **Run the Docker Container**:
113127
After building the image, you can start the container using:
128+
114129
```shell
115130
sudo docker run -d -p 4000:4000 -p 25:25 -v ./attachments:/React-TrashMail/mailserver/attachments -e REACT_APP_API_URL= -e REACT_APP_DOMAINS='["example.com"]' --name trashmail-container hppanpaliya/react-trashmail:latest
116131
```
132+
117133
This command starts the TrashMail application and exposes it on ports 4000 and 25 for mailserver.
118134

119135
3. **Accessing the Application**:
@@ -123,13 +139,12 @@ Ensure you have Docker installed and running on your machine before executing th
123139

124140
#### Docker environment variables and volume options used or can be added:
125141

126-
127-
| Option/Variable | Description |
128-
|-----------------|-----------------------|
129-
| `-e REACT_APP_API_URL=` | Sets the API URL. Leave empty or set to the backend URL if hosted externally. Example: `-e REACT_APP_API_URL=http://backendhost:4000` |
130-
| `-e REACT_APP_DOMAINS='["example.com", "example.org"]'` | Specifies the domains for the email service. Set to desired domains. |
131-
| `-v ./attachments:/React-TrashMail/mailserver/attachments` | Volume mount for attachments. Maps a local directory to a container directory. |
132-
| `-v /my/local/mongodb:/data/db` | (Optional) Volume mount for MongoDB data. Maps a local directory to the MongoDB data directory in the container. |
142+
| Option/Variable | Description |
143+
| ---------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- |
144+
| `-e REACT_APP_API_URL=` | Sets the API URL. Leave empty or set to the backend URL if hosted externally. Example: `-e REACT_APP_API_URL=http://backendhost:4000` |
145+
| `-e REACT_APP_DOMAINS='["example.com", "example.org"]'` | Specifies the domains for the email service. Set to desired domains. |
146+
| `-v ./attachments:/React-TrashMail/mailserver/attachments` | Volume mount for attachments. Maps a local directory to a container directory. |
147+
| `-v /my/local/mongodb:/data/db` | (Optional) Volume mount for MongoDB data. Maps a local directory to the MongoDB data directory in the container. |
133148

134149
These options and environment variables are crucial for configuring the TrashMail application within the Docker environment, especially for handling backend API communication and data persistence.
135150

mailserver/.prettierignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
build

mailserver/.prettierrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"semi": true,
3+
"trailingComma": "es5",
4+
"singleQuote": false,
5+
"printWidth": 150,
6+
"tabWidth": 2
7+
}

mailserver/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ The mail server can be configured using the `config.js` file located in the proj
2929
- `smtpPort`: The port number on which the SMTP server should listen.
3030
- `mongoURL`: The URL for connecting to the MongoDB database.
3131
- `dbName`: The name of the MongoDB database to be used.
32-
- `collectionName`: The name of the collection in the database to store the emails.
3332

3433
## Usage
3534

mailserver/attachmentRoutes.js

Lines changed: 0 additions & 15 deletions
This file was deleted.

mailserver/config.js

Lines changed: 0 additions & 9 deletions
This file was deleted.

mailserver/db.js

Lines changed: 0 additions & 35 deletions
This file was deleted.

0 commit comments

Comments
 (0)