Skip to content

Latest commit

 

History

History

README.md

Moon

MoonCode API

The API for the MoonCode app
api.mooncode.cc

Description

This project is the API used to power the other main packages in the monorepo: dashboard and vscode-extension. It is built on top of Nestjs and powered by trpc.

Project setup

To run the API, you need to first clone the repository

git clone https://github.com/Friedrich482/mooncode-monorepo.git

Then cd in the API

cd apps/api

Then install dependencies

npm install

Before continuing you'll need some environment variables: JWT_SECRET and DATABASE_URL.

Environment variables

  • NODE_ENV:

    NODE_ENV=production
  • DATABASE_URL: you can use:

    DATABASE_URL="postgresql://postgres:postgres@localhost:5432/mooncode"

    compose.yaml

    (Local database set up by docker compose as a docker volume. If you don't have docker installed, follow that link to the installation: Docker)

  • JWT_SECRET: Generate an SSL 64-character hexadecimal string.

    openssl rand -hex 32
  • GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET: you get them when you create credentials in the Google Cloud Console

  • GOOGLE_REDIRECT_URI:

    GOOGLE_REDIRECT_URI=http://localhost:3000/auth/google/callback
  • GOOGLE_LINKING_REDIRECT_URI:

    GOOGLE_LINKING_REDIRECT_URI=http://localhost:3000/auth/google/linking/callback
  • ONBOARDING_EMAIL, RESET_PASSWORD_EMAIL and UPDATE_EMAIL_EMAIL: those three can be obtained by creating an account on Resend and registering an email domain. For example:

    ONBOARDING_EMAIL=onboarding@<email_domain>
    RESET_PASSWORD_EMAIL=noreply@<email_domain>
    UPDATE_EMAIL_EMAIL=noreply@<email_domain>
  • RESEND_API_KEY: Resend API key

    RESEND_API_KEY=re_...

Compile and run the project

Compile :

npm run build

Then start:

npm run start:prod

Deployment

The API is currently deployed on api.mooncode.cc.

Containerization

To dockerize the application, you need to place yourself at the root of the monorepo, then

docker build -t mooncode-api -f apps/api/Dockerfile --progress=plain .

And to run a container called mooncode-api-container :

docker run -p 3000:3000 --name mooncode-api-container --env-file apps/api/.env mooncode-api:latest

License

MIT License © 2026