Deploy Xest API on Digital Ocean

Lindow Root
4 min readMay 3, 2024

--

image cover

What is Xest?

Xest is a lightweight Javascript API framework built by Cyprus Codes. It allows you to build REST APIs in the fastest way possible.

  • ✅ Use ExpressJS for building endpoints
  • ✅ Rich utility and database interaction library
  • ✅ Development ready Dockerized MySQL setup
  • ✅ Built-in authentication and role-based authorization
  • ✅ Easy learning curve if you are familiar with JavaScript
  • ✅ Xest CLI helps you generate SQL queries, API endpoints, database migrations, and seed data.

Xest framework is built on top of Express.js, which is one of the most popular Node.js libraries. It takes a “convention over configuration” approach which means developers are not required to configure anything by themselves, as Xest comes with sane defaults for everything ranging from the local development environment to testing, deployment, and many other aspects.

When an Xest project is created, a default project structure is created. If you follow the established conventions, you can develop a web application in much less time than you would need to develop a similar web application.

Learn more about it here: https://xestjs.com/docs/installation

How to Deploy a Xest API to Digital Ocean

Step 1: Create a Digital Ocean account, here: digital ocean

Step 2: Once your account is created, create a new project (or use the one created for you as default)

Screen for D.O to create a new project

Step 3: Create a new Database, on the Database Space, Choose MySQL as Database type, give your database cluster a name, and select your project.

Screen for creating a Database Cluster
Screen for creating a Database Cluster (continue)

Step 4: Finish your database configuration and copy your connection details, it should look like this:

username = doadmin
password = *****************************
host = xxxxxxxxxxx.ondigitalocean.com
port = your_port
database = database_name
sslmode = REQUIRED

Step 5: Go to App Platform and Create a new App, I will advise you to push your project on GitHub, it will be easy for the deployment.
Choose your repository and the main branch you want to use.

App Creation in D.O

In your Environment Variables add your connection details like this:

DB_NAME=database_name

DB_USER=doadmin

DB_PASSWORD=**************

sslmode=REQUIRED

DB_HOST=xxxxxxxxxx.ondigitalocean.com

DB_PORT=your_port

APP_ENVIRONMENT=PRODUCTION

JWT_SECRET=SUPER_DUPER_SECRET

PASSWORD_SALT=SECRET_SALT

Step 6: once finished, you will have something like this:

Showing that the app has been created.

On your Database screen, in your Overview panel, choose trusted sources and add your app name to the trusted sources

Step 7: Create your droplet, and remember to choose your project on the project input

Screen for creating a droplet on D.O

With This Your Digital Ocean is ready to deploy your Xest API project, only small changes are left in your Xest Files.

  1. run: npm install mysql2, Replace mysql with mysql2 in the database folder, like this
image showing how to replace mysql to mysql2

2. In the same folder add the port as DB_PORT, like this:

image showing how to add a port

3. Inside the swictEnvVars folder, add DB_PORT to KEYS_TO_SWITCH, like this:

image showing how to add DB_PORT as the key to switch

4. The most important change is to add the .do file that contains 2 YML files to your Xest Project, and replace the contains, with your project information.
find it on the digital ocean sample-expressjs repository: https://github.com/digitalocean/sample-expressjs/tree/main/.do

image of digital ocean’s sample-expressjs repository

That’s how to deploy your Xest API to Digital Ocean.

Thanks.

--

--