A repository to kick-start a Node.js API server project using Express and Typescript.
The purpose of this repository is to become a multi-template to offer a kick-start for a REST API project, having the option to choose from having multiple ORMs / packages / libraries from a little CLI application.
This is a starter Node.js API server project built on Express. It uses Typescript and is configured to use ESLint for linting and Jest for testing.
- Clone the repository
git clone https://github.com/sebi75/express-typescript-starter.git <project_name>
- Install dependencies
cd <project_name>
npm install
- Run local development server
npm run dev
- Use any REST client to test the API
GET http://localhost:8080/hello
- To run tests
npm test
This project uses [dotenv]
To add a new variable, add it to the .env
file and use it in the code as process.env.<variable_name>
Copy all the contents from .env.example to .env and update the values as needed.
This project uses Winston for logging. Winston is exported as a logger and can be used to log custom messages on demand. Also, it can be extended to push logs to files, external database, or any logging service.
All of these logs are written to console during development. Feel free to add production-specific loggers as and when needed.
-express-typescript-starter
├─ .gitignore
├─ README.md
├─ .env
├─ .env.example
├─ tsconfig.json
├─ package-lock.json
├─ package.json
├─ src
│ ├─ common
│ │ ├─ http-exception.ts
│ │ └─ logger.ts
│ ├─ controllers
│ │ └─ articles.controller.ts
│ │
│ ├─ controllers
│ │ ├─ helloController
│ │ ├─ hello.controller.ts
│ │ ├─ index.ts
│ │ ├─ HelloRequest.ts
│ │ └─zodRequestValidator.ts
│ │
│ ├─ types
│ │ ├─ index.ts
│ │ ├─ ErrorsEnum.ts
│ │ └─ StatusCodes.ts
│ │
│ ├─ utils
│ │ ├─ logger.ts
│ │ └─ requestValidationMiddleware.ts
│ │
│ ├─ routers
│ │ └─ helloRouter.ts
│ ├─ services
│ │ └─ db.service.ts
│ │ └─ debug.service.ts
│ │
│ ├─ app.ts