Skip to content

oc777/studDB

 
 

Repository files navigation

Typescript boilerplate

A small boilerplate of a minimal typescript express application with automatic client and server compilation (separate), live reload and automatic testing.

Keywords: Typescript, gulp, nodejs, express, handlebars, sass, livereload, mocha, chai.

Structure

The client directory contains all files for the client side of the application, sass and typescript/javascript files to be bundled and the handlebars templates. The bundled and compiled files will then be put into the public folder.

The server directory contains all server side scripts and modules. These files will be compiled to javascript and be put into the dist directory.

The test folder will contain all automated tests. These files are not compiled into javascript, but uses the typescript runtime environment ts-node instead, when running npm test.

Instructions

Rename or copy .env.example to .env, change the environment variables to your setups preferences. (Currently only used by docker, not the application.)

Install LiveReload in Google Chrome for automatic browser reload (and make sure it is enabled).

Without virtual environments

npm install -g nodemon typescript ts-node gulp-cli
# Install.
npm install

# Start server and watch for changes.
gulp watch

# Run test suite.
npm test

Using Docker

docker-compose up

Using Vagrant

(But really... uninstall Windows, and use Docker with a linux distro instead.)

vagrant up
vagrant ssh
docker-compose up

Quirks and workarounds

Linting errors in test scripts

To get rid of annoying TSlint errors in test files, add "tslint.exclude": "**/test/**/*.ts" to your user settings in VS Code.

Port not available after application crash

When a NodeJS-application crashes, it may report that the port used (EADDRINUSE) is already taken when trying to restart it. The following is a way to fix that on a linux system.

ps -ax | grep node

The output will show something like:

6316 ?        Sl     0:00 node dist/index.js

Find the row with the node command to start your application and note the process number, then run:

kill -9 6316

Cleaning up containers and images

WARNING!! THIS WILL REMOVE ALL CONTAINERS AND VOLUMES! (But only this image.)

docker rm $(docker ps -a -q) && docker rmi studdb_web && docker volume rm `docker volume ls -q -f dangling=true`

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 76.1%
  • HTML 19.9%
  • CSS 2.9%
  • JavaScript 1.1%