Sure! Below is a README.md
file that provides instructions for setting up and running the project on Windows, macOS, and Linux.
# CRUD Application with Login
This is a simple CRUD application with login functionality using Bun, Express.js for the backend, and HTML/JavaScript for the frontend. The application supports MySQL and PostgreSQL as optional database backends.
## Prerequisites
Before you begin, ensure you have the following installed:
- [Node.js](https://nodejs.org/)
- [Bun](https://bun.sh/)
- [MySQL](https://www.mysql.com/) or [PostgreSQL](https://www.postgresql.org/)
## Getting Started
### 1. Clone the Repository
```bash
git clone https://github.com/your-username/crud-login-app.git
cd crud-login-app
Run the initialization script to set up the project structure and install dependencies.
chmod +x init.sh
./init.sh
Edit the .env
file to set your database and secret key configurations.
DATABASE_TYPE=mysql # or postgres
DATABASE_HOST=localhost
DATABASE_PORT=3306 # or 5432 for PostgreSQL
DATABASE_NAME=myapp
DATABASE_USER=root
DATABASE_PASSWORD=password
SECRET_KEY=your_secret_key
Start the application using Bun.
bun start
The server will start on port 3000.
-
Open Git Bash or Command Prompt.
-
Navigate to the project directory.
-
Run the initialization script:
./init.sh
-
Start the application:
bun start
-
Open Terminal.
-
Navigate to the project directory.
-
Run the initialization script:
chmod +x init.sh ./init.sh
-
Start the application:
bun start
-
Open Terminal.
-
Navigate to the project directory.
-
Run the initialization script:
chmod +x init.sh ./init.sh
-
Start the application:
bun start
The frontend consists of simple HTML and JavaScript files located in the frontend
directory.
index.html
: Main CRUD interface.login.html
: Login page.main.js
: JavaScript functions for handling login, adding items, and fetching items.
To access the frontend:
- Open a web browser.
- Navigate to
http://localhost:3000/frontend/login.html
to access the login page. - Navigate to
http://localhost:3000/frontend/index.html
to access the CRUD interface (after logging in).
POST /auth/register
: Register a new user.POST /auth/login
: Login and receive a token.
GET /crud
: Get all items (requires authentication).POST /crud
: Add a new item (requires authentication).PUT /crud/:id
: Update an item (requires authentication).DELETE /crud/:id
: Delete an item (requires authentication).
This project is licensed under the MIT License. See the LICENSE file for details.
This `README.md` provides comprehensive instructions for setting up and running the project on Windows, macOS, and Linux. It includes sections on prerequisites, setup steps, and running the application on different operating systems.