githubEdit

TypeScript

Complete guide to host TypeScript applications on Discloud.

📁 Preparing the Files

Before uploading your project, you must exclude unnecessary files to optimize the deployment.

❌ Files to Exclude

Ensure the following files and directories are not included in your .zip:

- package-lock.json
- node_modules/
- .cache/
- .git/

📌 Use a .discloudignore file to automatically exclude these files.

🔗 Need help setting up your package.json or finding the main file?

chevron-right📦 About the dist folder (TypeScript: bot and site)hashtag
circle-info

For TypeScript apps, the dist/ folder is reserved for Discloud's BUILD output on both TYPE=bot and TYPE=site. If you set BUILD=... in your discloud.configarrow-up-right, Discloud generates the dist/ folder for you. Do not compress dist/ or upload files into it.

⚙️ Automatic build (recommended)

  1. Add BUILD in discloud.config (e.g., BUILD=npm run build).

  2. Configure tsconfig.json to output to dist/ and add scripts to package.json.

  3. We run BUILD before START and your app runs from dist/.

Example discloud.config (bot):

TYPE=bot
MAIN=dist/index.js
BUILD=npm run build
START=npm run start
RAM=100
VERSION=latest
ID=my-ts-bot

Example discloud.config (site):

TYPE=site
ID=mysite
MAIN=dist/server.js
BUILD=npm run build
START=npm run start
RAM=512
VERSION=latest

👜 Pre-built

  1. Produce output in build/ (do not use dist/).

  2. Omit BUILD from discloud.config.

  3. Point MAIN to the build/ folder entry file.

Example (bot):

TYPE=bot
MAIN=build/index.js
RAM=100
VERSION=latest
ID=my-ts-bot

Example (site):

TYPE=site
ID=mysite
MAIN=build/server.js
RAM=512
VERSION=latest

⚙️ Project Setup for TypeScript

You will typically compile TypeScript to JavaScript with tsc and run the compiled files.

package.json (scripts)

tsconfig.json (minimal)

circle-info

Discloud installs dependencies defined in your project. Ensure typescript is present (devDependency is fine) so the BUILD step can run tsc.


🌐 Hosting Websites & APIs with Express (TypeScript)

Before deploying your website or API on Discloud, ensure you meet the following requirements:

circle-check
circle-check
triangle-exclamation

Express (TS) example


✍️ Deploying Your Application

Once your project is configured and compressed, you can choose one of the following deployment methods on Discloud:


🔎 Quick recap of TypeScript specifics on Discloud

  • dist/ is reserved for Discloud builds on both TYPE=bot and TYPE=site.

  • If you pre-build locally, output to build/ and point MAIN to build/....

  • For TypeScript, always provide BUILD and START in discloud.config when shipping sources; MAIN should point to the runtime JS entry (usually dist/index.js).

  • For websites/APIs, your server must listen on port 8080.

Last updated