A basic fastify server template with TypeScript, ESM, ESLint and Prettier. Node.js 18+ is required.
- Clone or download the repository or click "Use this template" button on GitHub.
- Run
nvm use
– it will install the required Node.js version if it is not installed yet. - Install dependencies:
yarn
- Create
.env
file from.env.example
:cp .env.example .env
. Change the values if needed. - Run the server:
npm run dev
- Run
npm run build
- To start production application run
npm start
npm run dev
- start the server in development modenpm run build
- build the server for productionnpm start
- start the server in production mode (it is required to build the server first)npm run lint
- run ESLintnpm run typecheck
– run TypeScript type checkingnpm run prettier:test
– check formatting with Prettiernpm run prettier:write
– format files with Prettiernpm test
– run typechecking, linting and formatting checks
PORT
- port to run the server onHOST
- host to run the server onNODE_ENV
- environment the server is running in, can bedevelopment
,production
ortest
, default isproduction
CORS
- CORS configuration, default is empty string. Example:http://localhost:3000,http://localhost:3001
LOG_LEVEL
- log level, can befatal
,error
,warn
,info
ordebug
, default iserror
MIT