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
.envfile intoprocess.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
commonjsorbrowser) for different environments to help ESLint recognize them (used ineslint.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.jsonto run both typescript compiler andts-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 testsnpm run build: transpiles typescript to javascript in thedistfoldernpm run start: runsnode dist/index.js(you should have callednode run buildbefore)npm run dev: runsnodemonthat, usingconcurrently, both runs the typescript transpiler with thewatchoption and interprets the typescript files usingts-nodenpm run format: prettifies the codenpm run lint: runs the linternpm run lint:fix: runs the linter with thefixoptionnpm run check: runsformat,lint,buildandtestabove in sequence
Provided configuration files:
.end_development: copy this file to.envin 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 andts-nodeusingconcurrently)vite.config.ts: vitest configuration file
The "almost"-empty part:
theme/variables.ts: demonstrates export/import structure between files (look atsrc/index.ts)theme/__tests__/variables.test.ts: demonstrate test usageindex.ts: starts Express and demonstrates environment variable reading