Skip to content

ronknight/app-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

9 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

A simple Express.js application that saves and retrieves query parameters.

πŸ“‹ Requirements β€’ πŸš€ Usage β€’ πŸ›£οΈ Endpoints β€’ πŸ“œ Script β€’ πŸ” Visualization β€’ ⚠️ Disclaimer


πŸ“‹ Requirements

  • Node.js
  • Express.js

πŸš€ Usage

  1. Clone the repository:
    git clone https://github.com/ronknight/app-js.git
    
  2. Install dependencies:
    npm install
    
  3. Run the server:
    node app.js
    
  4. The server will start running on http://localhost:80

πŸ›£οΈ Endpoints

  1. 🌐 / (GET)

    • Saves the code and state query parameters
    • Returns a blank HTML page
  2. πŸ” /get-saved-name (GET)

    • Retrieves the saved code and state parameters
    • Returns a JSON object with the saved values

πŸ“œ Script

The app.js script sets up an Express.js server that:

  • πŸ’Ύ Saves code and state query parameters from the root endpoint
  • πŸ”’ Stores these values in memory
  • πŸ” Provides an endpoint to retrieve the saved values

πŸ” Visualization

Here's a flow chart that visualizes the structure and flow of the application:

graph TD
    A[Start Server] -->|Listen on PORT 80| B[Initialize Variables]
    B --> C{Receive Request}
    C -->|GET '/'| D[Save Query Parameters]
    D --> E[Return Blank HTML]
    C -->|GET '/get-saved-name'| F{Saved Code Exists?}
    F -->|Yes| G[Return JSON with Code and State]
    F -->|No| H[Return 404 Not Found]

    style A fill:#f9d71c,stroke:#333,stroke-width:2px
    style B fill:#f9d71c,stroke:#333,stroke-width:2px
    style C fill:#f9d71c,stroke:#333,stroke-width:2px
    style D fill:#a2d2ff,stroke:#333,stroke-width:2px
    style E fill:#a2d2ff,stroke:#333,stroke-width:2px
    style F fill:#f9d71c,stroke:#333,stroke-width:2px
    style G fill:#a2d2ff,stroke:#333,stroke-width:2px
    style H fill:#ffadad,stroke:#333,stroke-width:2px
Loading

This flow chart illustrates:

  • The server start and initialization process
  • How requests are handled for different endpoints
  • The logic flow for saving and retrieving parameters
  • Success and error states

Color coding:

  • Yellow: Main flow and decision points
  • Light Blue: Successful operations
  • Light Red: Error state

⚠️ Disclaimer

This application is for demonstration purposes only. In a production environment, consider:

  • πŸ” Implementing proper security measures
  • πŸ’½ Using a database for persistent storage
  • πŸ§ͺ Adding error handling and input validation

Made with ❀️ by Ronknight

About

πŸ“±A simple Express.js application that saves and retrieves query parameters.

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published