Skip to content

APXLabs/nodejs-api-starter

 
 

Repository files navigation

Node.js API Starter Kit


This project was bootstraped with Node.js API Starter Kit.

Tech Stack

Directory Layout

.
├── /build/                     # The compiled output (via Babel)
├── /src/                       # Node.js application source files
│   ├── /routes/                # Koa routes
│   ├── /app.js                 # Koa.js application
│   ├── /logger.js              # Winston Logger
│   ├── /env.js                 # Environment variables
│   ├── /server.js              # Node.js server (entry point)
├── /tools/                     # Build automation scripts and utilities
├── docker-compose.yml          # Defines Docker services, networks and volumes
├── docker-compose.override.yml # Overrides per developer environment (not under source control)
├── Dockerfile                  # Commands for building a Docker image for production
├── package.json                # List of project dependencies

Prerequisites

Getting Started

Just clone the repo and run docker-compose up:

git clone https://github.com/APXLabs/nodejs-api-startergit api
cd api                          # Change current directory to the newly created one
docker-compose up               # Launch Docker containers with the Node.js API app running inside

The API server must become available at http://localhost:5000.

Once the Docker container named api is started, the Docker engine executes node tools/run.js command that installs Node.js dependencies, compiles Node.js app from source files (see src) and launches it with "live reload" on port 8080.

In order to open a shell from inside the running "api" container, run:

docker-compose exec api /bin/sh

For the full list of automation scripts available in this project, please reffer to "scripts" section in the package.json file and the tools folder.

Testing

yarn lint                       # Find problematic patterns in code
yarn docker-test                # Run unit tests once inside a Docker container
yarn docker-test-watch          # Run unit tests in watch mode inside a Docker container

For more information visit http://facebook.github.io/jest/

Debugging

In order to run the app with V8 inspector enabled, simply replace node tools/run.js with node --inspect=0.0.0.0:9229 tools/run.js in either docker-compose.yml file or, even better, in docker-compose.override.yml. Then restart the app (docker-compose up) and attach your debugger to 127.0.0.1:9230 (see .vscode/launch.json)

NOTE: Try to merge as soon as the new changes land on the master branch in Node.js API Starter repository, otherwise your project may differ too much from the base/upstream repo.

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 93.2%
  • Dockerfile 6.8%