Skip to content

ryansat/Web-templates-gen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 

Repository files navigation

Sure! Below is a README.md file that provides instructions for setting up and running the project on Windows, macOS, and Linux.

README.md

# 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

2. Initialize the Project

Run the initialization script to set up the project structure and install dependencies.

chmod +x init.sh
./init.sh

3. Configure Environment Variables

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

4. Run the Application

Start the application using Bun.

bun start

The server will start on port 3000.

Running on Different Operating Systems

Windows

  1. Open Git Bash or Command Prompt.

  2. Navigate to the project directory.

  3. Run the initialization script:

    ./init.sh
  4. Start the application:

    bun start

macOS

  1. Open Terminal.

  2. Navigate to the project directory.

  3. Run the initialization script:

    chmod +x init.sh
    ./init.sh
  4. Start the application:

    bun start

Linux

  1. Open Terminal.

  2. Navigate to the project directory.

  3. Run the initialization script:

    chmod +x init.sh
    ./init.sh
  4. Start the application:

    bun start

Frontend

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:

  1. Open a web browser.
  2. Navigate to http://localhost:3000/frontend/login.html to access the login page.
  3. Navigate to http://localhost:3000/frontend/index.html to access the CRUD interface (after logging in).

API Endpoints

Authentication

  • POST /auth/register: Register a new user.
  • POST /auth/login: Login and receive a token.

CRUD Operations

  • 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).

License

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.

About

Web-templates-gen

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages