Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mze-runner/node-ts-boilerplate
A boilerplate to create a new node JS service. The codebase is on the typescript.
https://github.com/mze-runner/node-ts-boilerplate
expressjs jest mongoose nodejs typescript
Last synced: 21 days ago
JSON representation
A boilerplate to create a new node JS service. The codebase is on the typescript.
- Host: GitHub
- URL: https://github.com/mze-runner/node-ts-boilerplate
- Owner: mze-runner
- Created: 2020-05-16T07:14:20.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-03-04T18:28:30.000Z (almost 2 years ago)
- Last Synced: 2023-03-06T01:08:56.619Z (almost 2 years ago)
- Topics: expressjs, jest, mongoose, nodejs, typescript
- Language: TypeScript
- Homepage:
- Size: 774 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Node TypeScript Boilerplate
The boilerplate to rapidly create node js service based on TypeScript.
The boilerplate has bare minium dependencies but equipped with all you needed for initial configuration, e.g. ready-to-use run scripts, logging, setup to cope with environment variables.
## Context
- [Initial setup](#inital-setup)
- [Logging](#logging)
- [Environment variables](#environment-variables)## Initial setup
### Clone repository
You can download a zip from project repository page.
OR
Clone repository with help of `git`
```
git clone https://github.com/mze-runner/node-ts-boilerplate.git .
```### Install dependencies
```
npm install
```### Run project
Run in development mode
```
npm run dev
```Run in production mode
```
npm start
```Scripts behind the scene run `build` and produce code to `./build` folder.
## Logging
The Boilerplate leverage `winston` to provide logging capabilities.
Logs are being written to consol and `logs/app.log` file.Additionally, default output string format is customized per below
```
2020-05-17T08:27:03.340Z [info]: Express server listening on port 7000, environment: development
```## Environment variables
Following [The twelve-factor app](https://12factor.net/) environment variables, e.g. port, hosts, logins, password, etc. MUST not be stored as a constants in code.
The boilerplate utilize `dotenv` module and consume environment variable from `.env` file.
Feel free to update it whatever you need.
## ESLint
The boilerplate already has pre-configured eslint.
I did few tweaks to suite my own coding style. Feel free to enforce your own rules.What you can to to **fully reset** eslint configuration.
Run init and set up your preferences from the scratch.
```
npx eslint --init
npx eslint ./src/*.ts --fix
```
`eslint ./src/*.ts --fix` applies your changes to entire project housed under ./src folder.In case you want to make couple of tweaks, go and change `.eslintrc.json` file and run `npx eslint ./src/*.ts --fix `.
In case your fine with pre-defined rules, then you need to do nothing.