Deploy Xest API on Digital Ocean
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)
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.
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.
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:
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
With This Your Digital Ocean is ready to deploy your Xest API project, only small changes are left in your Xest Files.
- run: npm install mysql2, Replace mysql with mysql2 in the database folder, like this
2. In the same folder add the port as DB_PORT, like this:
3. Inside the swictEnvVars folder, add DB_PORT to KEYS_TO_SWITCH, like this:
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
That’s how to deploy your Xest API to Digital Ocean.
Thanks.