Skip to content

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

License

Notifications You must be signed in to change notification settings

MeerUzairWasHere/TypePEN

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

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

Install Dependencies

Run the following command to install the necessary dependencies:

cd backend && npm install
  • Make sure you have TypeScript installed globally. If not, you can install it globally with:

    npm install -g typescript

    Or, you can install TypeScript as a project dependency:

    npm install --save-dev typescript

Set Up Environment Variables

  1. Get a remote PostgreSQL database. You can use services like ElephantSQL, NeonDB, 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:

    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:

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:

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:

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):

npm run test

License

This project is licensed under the MIT License - see the 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!

About

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

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published