Skip to content

promise-app-team/promise-api

Repository files navigation

Promise API

Promise API Server

Table of Contents

Development

Prerequisites

Installing Dependencies

This project is using bun.js as a typescript runtime & toolkit.

$ bun install

Setup Environment Variables

Copy .env.example to .env and fill the variables.

$ cp .env.example .env

Setup MySQL Database

Using docker-compose to setup MySQL.

It will create a dockerdata directory in the project root and store the database data.

$ make start_mysql

If you want to remove the database, use the following command.

$ make stop_mysql

# if you want to remove the database data as well
$ rm -rf dockerdata

Run Local Server

Run the following commands to start the local development server.

It will run on http://localhost:$PORT.

# development mode
$ bun run start:dev

# production mode
$ bun run build
$ bun run start:prod

Run Local Server with HTTPS

Run the following commands to start the local development server with HTTPS.

It will run on https://api.local.promise-app.com.

$ make start_https # It will ask you for a password.

If you want to remove the HTTPS certificate, use the following command.

$ make stop_https # It will ask you for a password.

Database Migration

For Development Environment

If you are running the migration for the first time, you need to initialize it.

It will also create dummy data for testing.

$ bun run migrate:init

Edit schema.prisma to define the database schema.

And then run the following commands to migrate the database.

$ bun run migrate

# to check the migration status
$ bun run migrate:stat

For Remote Environment

Must be able to access the remote database.

# checkout to develop branch and pull the latest code
$ git checkout develop
$ git pull origin develop

# copy env-cmdrc file and fill the environment variables
$ cp .env-cmdrc.example.js .env-cmdrc.js

# deploy migration
$ bun run migrate:dev