Skip to content

Getting Started Quick Start Guide

Ahmad Nasriya edited this page Oct 26, 2024 · 1 revision

Welcome to HyperCloud! Follow these simple steps to start building with HyperCloud.

1. HyperCloud Installation

Make sure you have Node.js installed. Then, install HyperCloud via npm:

npm install @nasriya/hypercloud

2. Importing

Importing in ECMAScript Modules (ESM)

import hypercloud from '@nasriya/hypercloud';

Importing in CommonJS Modules

const hypercloud = require('@nasriya/hypercloud').default;

3. Creating & Initializing a server

// Create a new server
const server = hypercloud.Server();

// (Optional) Set the main server so you can use it anywhere
hypercloud.server = server;

4. Defining routes

For now, you only have a server that serves a 404 page on any path, so let's define more routes now using the server's Router.

const router = server.Router();

// Define a route for the homepage
router.use('/', (request, response, next) => {
    response.status(200).send({ data: '<h1>Hello, WOrld!</h1>' })
})

5. Start listening

To start listening for requests just call the listen method on the server.

server.listen();        // Prints ⇨ HyperCloud Server is listening on port #80
// OR
server.listen(5000);    // Prints ⇨ HyperCloud Server is listening on port #5000

For secure servers

server.listen();        // Prints ⇨ HyperCloud Server is listening securely on port #443
// OR
server.listen(8443);    // Prints ⇨ HyperCloud Server is listening securely on port #8443

Congratulations! Your server is now ready to handle requests.


Additional Resources

  • Configuration Tips: Check the Configuration page for tips on structuring your server settings.
  • Core Features: Visit Core Features for information on available modules and features.

This guide covers the basics. Once set up, explore other documentation pages to dive deeper into HyperCloud’s capabilities.