Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/meeruzairwashere/typepen

A TypeScript-based backend starter with PostgreSQL, Express, and Node.js. Flexible and frontend-agnostic—connect with React, Angular, Vue, or any framework!
https://github.com/meeruzairwashere/typepen

backend docker express nodejs postgres prisma

Last synced: 7 days ago
JSON representation

A TypeScript-based backend starter with PostgreSQL, Express, and Node.js. Flexible and frontend-agnostic—connect with React, Angular, Vue, or any framework!

Awesome Lists containing this project

README

        

# TypeScript Backend Starter with PostgreSQL, Express, and Node.js

A flexible backend starter built with **TypeScript**, **PostgreSQL**, **Express**, and **Node.js**. This boilerplate is designed to be backend-agnostic, allowing you to easily connect it with any frontend framework, such as **React**, **Angular**, **Vue**, or any custom solution.

## Features

- **TypeScript**: Strongly typed JavaScript for better development experience.
- **Express**: Fast, minimal web framework for Node.js.
- **PostgreSQL**: Powerful, open-source relational database.
- **Backend-Agnostic**: Ready to connect with any frontend framework.
- **Easy Setup**: Simple steps to get up and running.

## Requirements

- **Node.js** (v14 or later)
- **PostgreSQL** (v12 or later)

## Getting Started

### Clone the Repository

```bash
git clone https://github.com/MeerUzairWasHere/TypePEN.git
cd TypePEN
```

---

### Install Dependencies

Run the following command to install the necessary dependencies:

```bash
cd backend && npm install
```

- **Make sure you have TypeScript installed globally**. If not, you can install it globally with:

```bash
npm install -g typescript
```

Or, you can install TypeScript as a project dependency:

```bash
npm install --save-dev typescript
```

### Set Up Environment Variables

1. **Get a remote PostgreSQL database**. You can use services like [ElephantSQL](https://www.elephantsql.com/), [NeonDB](https://neon.tech/), or any other PostgreSQL provider to create a database instance.

2. **Rename the `.env.example` file** to `.env` and paste the PostgreSQL connection string into the `DATABASE_URL` variable:

Example:
```env
DATABASE_URL=your-postgresql-connection-string
```

Make sure to replace `your-postgresql-connection-string` with the actual URL you get from your PostgreSQL provider.

### Running Database Migrations

For the **first-time database migration**, run the following command:

```bash
npm run dev:migrate --init
```

This will create the necessary tables and apply the initial migrations to your database.

For **subsequent migrations**, use the following command:

```bash
npm run dev:migrate your-migration-name
```

Replace `your-migration-name` with the appropriate name for the migration you want to apply.

### Running the Backend

To **start the backend normally**, use the following command:

```bash
npm run dev
```

After running the backend, you will see a log message like this in the terminal:

```
Server is listening on http://localhost:3000/
```

The server will be running on whatever port is specified in your `.env` file (default is port 3000). You can now connect your backend to any frontend framework (React, Angular, Vue, etc.) and start building your application!

#### **First-time Run**

- On the **first-time** run of the application, it will redirect you to a documentation page. This is typically used for API documentation generated by Swagger UI.

**Note**: If you do not want the Swagger UI documentation page to appear, **comment out or remove** the related Swagger UI code in your `app.ts` or wherever it is configured. This can be found in the section where you have set up API documentation.

## Connecting with Frontend Frameworks

This backend is designed to be easily connected with **React**, **Angular**, **Vue**, or any other frontend framework. You can create RESTful API endpoints and consume them on the frontend.

## Testing (Coming Soon, Stay Tuned!)

You can add tests to the `tests` folder and run them using your preferred testing framework (e.g., Jest, Mocha).

To run tests (once they’re set up):

```bash
npm run test
```

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

---

### Feel free to contact me!

If you have any questions or need further assistance, feel free to reach out to me. I'm happy to help!