Skip to content

cola-coding-lab/api-backend

Repository files navigation

CoLa VCL API

Node.js/Express based ReST API for CoLa project.
Especially for the Online Editor.

Rewrite, based on express-ts

by Harald Schwab

For full documentation, see here.

About

API/Backend for VCL Frontend.

Prerequisites

When developing locally, you need Node.js, we recommend the current ( 03.2023) LTS 18.x.

A useful tool to manage different versions of Node.js locally would be NVM.

Clone this repository and install node packages using npm.

git clone https://mode.fh-joanneum.at/cola/vcl/api-service
cd api-service
npm ci --silent

Now, you can run the local development server.

npm run start:dev

To build the project, run npm run build or take a look into the Docker section.

Because linting is set to force UNIX linebreak style, on windows run:

git config --local core.autocrlf false

to avoid errors.

Configuration

See .env.example for custom configuration. Create a copy cp .env.example .env and setup your configuration.

Name Description Default
SERVICE_PORT Port, where service is listening 8605
NODE_ENV Set environment for application development
MONGO_HOST database url/hostname for MongoDB, should not be set when using docker-compose empty

Docker

I would recommend to directly use docker-compose.

  1. Build docker image
docker build --no-cache -t "vcl-api-service" .
  1. Run docker container
docker container run -it -d -p 8605:8605 --name vcl-api-service vcl-api-service

Check log-output

docker container logs -f vcl-api-service

Stop container

docker container stop vcl-api-service

Testing

We're using Jest for testing, you can find some example tests inside of test. With the help of supertest we also can do some End2End-Testing without the need of a separate running node-server.

Run tests locally

npm test

Run tests in watching mode

npm run test:watch

Run tests with coverage (you can find the coverage report in test/coverage).

npm run test:coverage

Documentation and Contribution rules

Use Conventional Commits specification for commit messages.

<type>([optional scope]): <description>

[optional body]

[optional footer(s)]

Types:

  • fix: a bugfix (add Issue number as scope, e.g. fix(#13): ...)
  • feat: a new feature
  • BREAKING CHANGE: a breaking change
  • docs: documentation only
  • ...

Useful links

About

ReST API backend for VCL

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •