This is a Node.js project implementing a Model-View-Controller (MVC) architecture with authentication operations. The project uses Express
for the web framework, Sequelize
for ORM with SQLite3
as the database, and Passport
with bcryptjs
for authentication.
- Express: Web framework for building the application.
- Express-Session: Middleware for session management.
- Pug: Templating engine for rendering views.
- Sequelize: ORM for database operations.
- SQLite3: Database engine.
- Bcryptjs: Library for hashing passwords.
- Passport: Authentication middleware.
- Passport-Local: Passport strategy for username and password authentication.
This project is based on a tutorial from LogRocket Blog.
This project is licensed under the MIT License. See the LICENSE file for more details.
To get started with this project, follow these steps:
-
Clone the repository:
git clone https://github.com/EnAnsari/basic-authentication-mvc-nodejs
-
Navigate to the project directory:
cd basic-authentication-mvc-nodejs
-
Install dependencies:
npm install
-
Create and configure the database:
The project uses SQLite3. By default, a database file will be created in the root directory when you run the application.
- Create a
.env
file:
Create a .env
file in the root directory of your project and add the necessary environment variables. For example:
SESSION_SECRET=your-session-secret
Adjust these settings according to your needs.
To start the application, use the following command:
npm start
By default, the application will run on http://localhost:8080
.
- Authentication: Users can register, log in, and manage their sessions.
- MVC Structure: The application follows the MVC architecture.
- Model: Defines the data structure and interacts with the database.
- View: Renders the HTML using Pug templates.
- Controller: Contains the logic for handling user requests and responses.
We welcome contributions to improve the project! If you'd like to contribute, please follow these steps:
-
Fork the repository on GitHub.
-
Clone your fork:
git clone https://github.com/EnAnsari/basic-authentication-mvc-nodejs
-
Create a new branch for your feature or bugfix:
git checkout -b feature/your-feature
-
Make your changes and commit them:
git add . git commit -m "Add your message here"
-
Push your changes to your fork:
git push origin feature/your-feature
-
Submit a Pull Request on GitHub, describing your changes and any relevant information.
For any questions or feedback, please reach out to Rahmat2022a@gmail.com.