A MERN stack is comprised of the following technologies that can be used to create a full-stack web application:
This project provides user login / logout functionality, account creation, and real time messaging using websockets.
- Intuitive UI design.
- Autoscroll to the bottom of the page for long chats
- Status indicators for when a user is online or offline
- Easily scalable NoSQL database structure.
More information autogenerated by Vite can be found below in the "More Vite Information" section.
-
Clone this repository by running the following command from the Git Bash console:
git clone https://github.com/mejia-dev/mernchatapp.git
-
Navigate to the project directory, then to the
api
subdirectory:cd mernchatapp/api
-
Create a new file called
.env
:touch .env
-
Create a new MongoDB database (refer to the official documentation if needed).
-
Add the deployment URL (starting with
mongodb+srv://
) into the.env
file in the following format, replacingYOUR_URL_HERE
with the url:MONGO_URL= "YOUR_URL_HERE"
-
Next specify two more keys in
.env
.- The JWT_SECRET must be a secret key for the JWT generation. This can be set to anything.
- The CLIENT_URL must be set to the server address that connections will be made from. The default should be
http://localhost:5173
.
MONGO_URL = "mongodb+srv://mernchat:[email protected]/?retryWrites=true&w=majority&appName=Cluster0" JWT_SECRET="YOUR_SECRET_KEY" CLIENT_URL="http://localhost:5173"
-
Run the following command to install dependencies:
npm install
-
Once the dependencies install, run the following command to start the backend API:
node index.js
-
Leave the terminal open, then start another terminal in the project directory to navigate to the
client
folder and run the start command to run the live development server:-
cd mernchatapp/client
-
npm run start
-
To generate a built version of the application, use npm run build
.
- none
MIT License
Copyright (c) 2024 Aaron Mejia
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Currently, two official plugins are available:
- @vitejs/plugin-react uses Babel for Fast Refresh
- @vitejs/plugin-react-swc uses SWC for Fast Refresh
If you are developing a production application, we recommend updating the configuration to enable type aware lint rules:
- Configure the top-level
parserOptions
property like this:
export default {
// other rules...
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
project: ['./tsconfig.json', './tsconfig.node.json'],
tsconfigRootDir: __dirname,
},
}
- Replace
plugin:@typescript-eslint/recommended
toplugin:@typescript-eslint/recommended-type-checked
orplugin:@typescript-eslint/strict-type-checked
- Optionally add
plugin:@typescript-eslint/stylistic-type-checked
- Install eslint-plugin-react and add
plugin:react/recommended
&plugin:react/jsx-runtime
to theextends
list