Backend API Setup
Configure your backend API connection
API Configuration
Launchtoday comes with a backend service that your mobile app will make API requests to. The service provides secure endpoints for payment processing through Stripe, with planned expansion for push notifications and other features.
Prerequisites
Before getting started, you should be familiar with:
- TypeScript: The backend services are written in TypeScript
- Koa: Used as the web framework for building backend services
- Docker: Required for containerizing the application
- fly.io: Used for deploying and hosting the backend services
Repository Setup
First, clone the repository and install dependencies:
The project contains a .nvmrc
file which specifies Node.js version 18.18.2.
You can either: - Use this version by running nvm use
to automatically
switch to 18.18.2 - Or modify the .nvmrc
file to use your preferred Node.js
version (must be ≥18.18.2)
Make sure you also have Yarn installed on your system before running these commands.
Environment Setup
Copy the example environment file to create your .env
using the following command:
Your .env
file should look like this:
Don’t worry about the Stripe and Supabase keys for now, we’ll get to them later in the Stripe Setup and Supabase Setup sections.
Running the API Service
Once you have the repository setup and the environment variables set up, you can start the API service using the following command:
Your terminal should output something like this:
You can verify that the API service is running by navigating to http://0.0.0.0:3000/hello
in your web browser. You should see a JSON response like this:
You can also run the following curl command to verify that the API service is running:
Deploying the API Service
As previously mentioned, the API service is deployed to fly.io. There are several other alternatives to fly.io, but for now we’ll focus on deploying with fly.io. Ensure you have a fly.io account and are logged in before proceeding. You can run the following command to deploy the API service:
- Run
fly auth signup
if you don’t have an account - Run
fly auth login
to login to your fly.io account - Run
fly launch
to launch the API service
After making API changes, you can deploy the changes by running fly deploy
.