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.
- 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.
- Node.js (v14 or later)
- PostgreSQL (v12 or later)
git clone https://github.com/MeerUzairWasHere/TypePEN.git
cd TypePEN
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
-
Get a remote PostgreSQL database. You can use services like ElephantSQL, NeonDB, or any other PostgreSQL provider to create a database instance.
-
Rename the
.env.example
file to.env
and paste the PostgreSQL connection string into theDATABASE_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.
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.
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!
- 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.
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.
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
This project is licensed under the MIT License - see the LICENSE file for details.
If you have any questions or need further assistance, feel free to reach out to me. I'm happy to help!