Giter Site home page Giter Site logo

node-ts-service's Introduction

Node Typescript project

A basic, pre-configured Node.js app to be used as starting template using for example degit. Includes the following pre-configured:

  • Node 20
  • Typescript 5 with path mapping from @/* to src. So @/modules/foo maps to ./src/modules/foo. The path mapping is fixed automatically when building, so the resulting Node.js JS project can resolve files.
  • Eslint configured for Typescript
  • Prettier
  • Jest testing using TS, via ts-jest.
  • Uses esbuild instead of ts-node for developing. Blazing fast you know.
  • Dockerfile with multi-step build based on slim image (only 185Mb base image size after compilation).
  • Basic Github pipeline (ci.yml) that caches node_modules, and then runs lint, test and compile TS on push and pull_request to main branch only.

A note on slim base image: see here Image Variants regarding this. In case something wrong happens during the build, switch to node-20 image for safety, specially if using dependencies with native binaries (like sharp for image manipulation and so on).

Node version 20, all dependencies latests versions as of May 20th 2024.

Usage

Create a new Node service based on this repo with

npx degit cdelaorden/node-ts-service

This is fast and doesn't include git info. Is just a fresh copy of the latest version.

What next?

  1. Modify the README and package.json details, so they don't point to this repository anymore (url, author, name, bugs, homepage and so on).
  2. Add your preferred stack! Choose a DB, add a docker-compose.yaml for local development, add dependencies and code your app. This simply is the starting point, with some commands and configurations ready.

Development

  • npm run dev Starts dev environment locally with superfast esbuild transpilation + nodemonfor hot reload.

  • npm test Single run of all tests with Jest

  • npm run tdd Runs test with Jest in watch mode

  • npm run ts-compile Compiles TS with tsc (slower, but real type checking)

  • npm run lint Runs Eslint

  • npm run coverage Runs Jest and outputs coverage info

Production

  • npm run build Compiles TS to build output (which is .gitignored)

  • npm run start For production running, executes JS-compiled app in build/index.js (needs previous build step)

  • docker build . Builds the Docker image. Remember to tweak the Dockerfile if custom dependencies are needed inside the container for your app.

node-ts-service's People

Contributors

cdelaorden avatar monkeyandres avatar

Stargazers

 avatar  avatar

Watchers

 avatar  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.