Lesuuh / Zuri-server

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Simple Node.js Server with Asynchronous Response and CORS Support

Requirements

  • Node.js installed on your system

Getting Started

  1. Clone this repository to your local machine or download the files.
  2. Navigate to the project directory in your terminal.
  3. Install dependencies by running the command:
    npm install
  4. Start the server by running the command:
    node server.js
  5. The server should now be running on port 9000.

Endpoints

GET /

Returns information about the user's CPU and OS.

Example Response

{
  "cpu": [{...}],  // Array of CPU information objects
  "uptime": 123456,  // System uptime in seconds
  "machine": "x64",  // Machine architecture
  "version": "11.0.0",  // Node.js version
  "userInfo": {...},  // User information object
  "type": "Darwin",  // OS type
  "totalmem": 17179869184,  // Total system memory in bytes
  "freemem": 581029376,  // Free system memory in bytes
  "release": "20.6.0",  // OS release version
  "platform": "darwin",  // Platform
  "hostname": "localhost",  // Hostname
  "homedir": "/Users/username",  // User's home directory
  "arch": "x64"  // OS architecture
}

CORS Support

Cross-Origin Resource Sharing (CORS) is enabled for all endpoints, allowing requests from any origin.

Error Handling

  • 404 Not Found: Returned when the requested URL is not supported.
  • 405 Method Not Allowed: Returned when the HTTP method used is not supported.

Configuration

  • The server listens on port 9000 by default. You can modify the port variable in server.js to change the port.
  • The timeoutDuration variable in server.js determines the maximum delay for simulating asynchronous responses.

Notes

This server is designed by Lesuuh (xnight) for demonstration purposes and may not be suitable for production use without further enhancements.

About


Languages

Language:JavaScript 100.0%