Skip to content

Project-Kampong/kampong-backend-core

Repository files navigation

Kampong

Kampong Core Backend

Core Backend in NestJS and MongoDB for Project Kampong.

Build Passing CodeQL Passing Total alerts Language grade: JavaScript

Quick Start

  1. Set up database. Refer to this guide on creating a MongoDB cluster on Atlas.

    NB: After creating the cluster, take note of the cluster's Connection String.

    NB2: Skip this step if setting up with VSCode Dev Container.

  2. Set up config variables

    a. In the file config/sample.env, duplicate the file and rename it to config/config.env.

    b. Fill in all credentials required in the new file, as follows:

    Variable Value
    NODE_ENV development / production
    PORT 5050
    MONGO_URI Copy your MongoDB Connection String from previous step here.
    (Skip if setting up with VSCode Dev Container)
  3. See App Setup to setup the app

App Setup

There are 3 ways to setup the app

  1. Develop in VSCode Dev Container (RECOMMENDED)
  2. Run with Docker Compose
  3. Manual installation

Develop in VSCode Dev Container

Recommended for development.

Pre-requisite

Steps

  1. Open repo in VSCode.
  2. VSCode will prompt to open the workspace in the remote container. Folder contains a dev container configuration file. Reopen folder to develop in a container
  3. Select Reopen in container, VSCode will setup a fully ready environment.
  4. Refer to the bottom left-hand corner of VSCode to verify that container is setup. It should have a text stating Dev Container: Kampong Backend Core Development
  5. To run app, see Running the app

NB: After changing env vars in config/config.env, the devcontainer must be re-built: CMD + SHIFT + P > Select Rebuild and Reopen in Container

Run with Docker Compose

Recommended for quick setup. (Eg. to boot app quickly for testing with a frontend framework)

Pre-requisite

Steps

  1. Ensure config/config.env is set up in your local repo.
  2. Run docker-compose up
  3. App will setup and run automatically.

Manual installation

Pre-requisite

App requires the following dependencies to be installed locally (in the following order):

NB: NestJS installation is required for development. It is not required to run the app.

Steps

  1. Run nvm install && nvm use
  2. Verify node version with node -v
  3. Run npm install
  4. To run app, see Running the app

Running the app

# development watch mode
$ npm run start:dev

# production mode
$ npm run start:prod

Test

# unit tests
$ npm run test

# test coverage
$ npm run test:cov

API Documentation + Test Endpoints

Swagger API

GraphQL Playground

About

Kampong core backend in NestJS

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •