Giter Site home page Giter Site logo

ts-node-project's Introduction

Typescript Node Environment

A minimal node-based development environment configured to use Typescript, Jasmine, Istanbul and Docker.

Features

  • Code and tests all written and compiled from Typescript
  • Supports using 3rd party imports using ES6-style importing
  • Tests and code coverage in Typescript
  • Fast dev env
  • Build a Docker container

Commands

Installing

Call npm i to install dependencies.

Running

Call npm start to run the program, located at src/index.ts.

Running tests

Call npm test to run through the full suite of tests in one run.

Testing (bdd)

Call npm run test-bdd to run through the full suite of bdd tests in one run.

Testing (coverage)

Call npm run coverage to view the html docs of the coverage report (a coverage xml file and html docs are automatically generated after running the tests).

Building Docker

Call npm run docker-build to build a Docker container for the project.

Running Docker

Call npm run docker-run to run the Docker container locally, routing local ports.

How to

Adding code

The entry file for compiling and running the Typescript is 'src/index.ts'. Add your own code by creating a file with the '.ts' extension in the src directory (or subdirectory).

Writing tests

Add your unit tests to the src directory (or subdirectory) with the file extension '.spec.ts'.

Mocking imports

You can use the Mockery library to override the imports for unit testing

Opening additional ports

When extra ports are needed to be exposed, these will need adding to the Dockerfile, the following snippet can be used:

EXPOSE {port}

In addition, the package.json file will need modifying, the extra port will need adding to the map when running the Docker instance. For example, port 8080 is currently mapped to the local port 8080:

{
  ...
  "scripts": {
    ...,
    "docker-run": "docker run -p 8080:8080 app"
  },
  ...
}

Add 3rd party libraries

Install the library via:

npm i {libraryName}

e.g.

npm i jquery
npm i rxjs

Start using the library via ES6 import:

e.g.

import * as jquery from 'jquery';
import { Subject } from 'rxjs';

Licence

All code is licenced under MIT.

ts-node-project's People

Contributors

mrboggieman avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.