Skip to content

chathuraprasanga/express-backend-ts

Repository files navigation

Express Backend with TypeScript

This project is a basic Express.js backend application built with TypeScript.

Features

  • TypeScript for better development experience.
  • Includes core functionalities such as CORS, environment variables, and JSON handling.
  • Uses bcryptjs for password hashing and jsonwebtoken for authentication.
  • Integrated with MongoDB via mongoose.

Requirements

  • Node.js (v16 or higher)
  • npm or yarn

Setup Instructions

1. Clone the Repository

git clone <repository-url>
cd <repository-folder>

2. Install Dependencies

npm install

3. Configure Environment Variables

Create a .env file in the root directory and set the following variables:

env PORT=3000 || 3000


### 4. Run the Application
```bash
For Development:
npm run dev
#### or
For Production:
Build the application:
npm run build
#### or
Run the compiled code:
npm start
.
├── src
│   ├── server.ts         # Main server file
│   ├── utils
│   │   └── startup.ts    # ASCII art startup message
├── .env                  # Environment variables
├── package.json          # Project configuration
├── tsconfig.json         # TypeScript configuration
├── README.md             # Documentation

Example Endpoint Test the main endpoint after starting the server:

/GET

Scripts

dev: Start the server in development mode with live reload.
build: Compile TypeScript to JavaScript.
start: Run the compiled server in production.

Dependencies

express: Web framework.
dotenv: Environment variable management.
cors: Cross-origin resource sharing.
bcryptjs: Password hashing.
jsonwebtoken: Token-based authentication.
mongoose: MongoDB ORM.
Dev Dependencies
typescript: TypeScript compiler.
nodemon: Live reload for development.
eslint and prettier: Code linting and formatting.

License This project is licensed under the MIT License.

About

Basic typescript backend boilerplate

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors