Skip to main content

Introduction

This guide covers deploying Express.js applications on Shard Cloud, from initial setup to production deployment.

Creating Your Project

Before starting, ensure you have Node.js and npm installed. Download from the official Node.js website.

Installing Express

npm init -y
npm install express

Basic Express Application

Create an index.js file:
index.js
import express from "express";

const app = express();
const port = 80;

app.get("/", (req, res) => {
  res.send("Hello World!");
});

app.listen(port, () => {
  console.log(`Express app listening on port ${port}`);
});
Port 80 is required for web applications on Shard Cloud.

Package.json Configuration

package.json
{
  "name": "my-express-app",
  "version": "1.0.0",
  "type": "module",
  "main": "index.js",
  "scripts": {
    "start": "node index.js"
  },
  "dependencies": {
    "express": "^4.18.0"
  }
}

Shard Cloud Configuration

Create a .shardcloud file in your project root:
.shardcloud
DISPLAY_NAME=My Express API
DESCRIPTION=Express.js REST API
MAIN=index.js
MEMORY=512
VERSION=recommended
SUBDOMAIN=my-express-api

Deploying

1

Prepare Your Files

Ensure you have: - index.js (or your entry file) - package.json - .shardcloud
2

Exclude Unnecessary Files

Remove before zipping: - node_modules/ - package-lock.json
3

Create ZIP Archive

Compress your project folder into a .zip file.
4

Upload to Shard Cloud

Go to Shard Cloud Dashboard and click “New app” to upload your project.

Additional Resources

For more information about Express, visit the official Express documentation.

Troubleshooting

  • Verify your MAIN file path is correct - Check that port 80 is used for web applications - Ensure all dependencies are in package.json
  • Confirm SUBDOMAIN is set in .shardcloud - Wait a few moments after deployment for DNS propagation