Skip to content

Vangaorth/TypescriptExpressVitest

Repository files navigation

This is an almost-empty template repository to use Express with Typescript and Vitest.

Make sure to copy .env_development into .env before running.

Included:

  • Express: a minimal and flexible web application framework that provides a robust set of features for building APIs and web servers
  • Dotenv: a zero-dependency module that loads environment variables from a .env file into process.env

Dev Dependencies:

  • Typescript: strongly typed superset of JavaScript that adds static types to help catch errors early during development
  • Vitest: testing framework designed to be fast, modern, and compatible with Jest's API (supports Typescript out of the box)
  • Prettier: opinionated code formatter that ensures a consistent style across the entire codebase
  • ESLint: static analysis tool used to identify and fix problematic patterns or code quality issues in JavaScript and TypeScript
  • Globals: package providing a comprehensive list of global identifiers (like commonjs or browser) for different environments to help ESLint recognize them (used in eslint.config.mjs)
  • Nodemon: tool that monitors for any changes in your source code and automatically restarts your server during development (used in script npm run dev)
  • Concurrently: utility that allows to run multiple commands (like a compiler and a server) simultaneously in a single terminal (used in nodemon.json to run both typescript compiler and ts-node)
  • TS-Node: TypeScript execution engine that allows to run TypeScript files directly without manually pre-compiling them to JavaScript (used to interpret typescript files on the go, when run with script npm run dev)

Available scripts:

  • npm run test: runs tests
  • npm run build: transpiles typescript to javascript in the dist folder
  • npm run start: runs node dist/index.js (you should have called node run build before)
  • npm run dev: runs nodemon that, using concurrently, both runs the typescript transpiler with the watch option and interprets the typescript files using ts-node
  • npm run format: prettifies the code
  • npm run lint: runs the linter
  • npm run lint:fix: runs the linter with the fix option
  • npm run check: runs format, lint, build and test above in sequence

Provided configuration files:

  • .end_development: copy this file to .env in order to have environment variables
  • .nvmrc: pins the node version
  • .prettierrc: code-formatting rules (for prettier)
  • eslint.config.mjs: linter rules (for ESLint)
  • nodemon.json: nodemon configuration (to run both typescript compiler and ts-node using concurrently)
  • vite.config.ts: vitest configuration file

The "almost"-empty part:

  • theme/variables.ts: demonstrates export/import structure between files (look at src/index.ts)
  • theme/__tests__/variables.test.ts: demonstrate test usage
  • index.ts: starts Express and demonstrates environment variable reading

About

A base repository with (almost) minimal configuration for Express with Typescript and Vitest

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors