This monorepo hosts a blog site’s frontend and backend. The frontend, built with Next.js, uses SSR and SSG for performance and SEO, displaying dynamic content from the backend API. The backend, built with Node.js and TypeScript, uses PostgreSQL with TypeORM, supporting migrations, seeding, and environment-specific configs.
- Project Overview
- Frontend Setup (Next.js)
- Backend Setup (Node.js with TypeScript and PostgreSQL)
- Environment Variables
- Running the Project
- Building for Production
- Database Migrations and Seeding
- Contributing
- License
This project consists of a frontend built with Next.js for dynamic blog content display and a backend built with Node.js, TypeScript, and PostgreSQL for content management. The backend API integrates with the frontend to provide blog content dynamically.
- Node.js (v14+)
- npm or yarn
-
Clone the repository:
git clone git@github.com:Linal180/nextjs-template.git cd nextjs-template -
Install dependencies:
npm install
or with yarn:
yarn install
-
Set up environment variables by creating a
.env.localfile:NEXT_PUBLIC_API_URL=<your_backend_api_url>
To start the development server:
npm run devor with yarn:
yarn devTo create an optimized production build:
npm run buildTo start the production server:
npm startor with yarn:
yarn start- Node.js (v14+)
- PostgreSQL
- TypeORM
-
Clone the repository:
git clone git@github.com:Linal180/nodejs-template.git cd nodejs-template -
Install dependencies:
npm install
-
Configure environment variables by creating
.env.localand.env.prodfiles for local development and production, respectively:DB_HOST=localhost DB_PORT=5432 DB_USERNAME=your_username DB_PASSWORD=your_password DB_DATABASE=your_database
-
Create the database:
npm run create-database
To start the development server:
npm run devTo start the production server:
npm run startTo generate a new migration:
npm run typeorm:generate -- NameOfMigrationTo run migrations:
npm run typeorm:migrateTo revert the last migration:
npm run typeorm:revertTo drop the database schema:
npm run typeorm:dropTo seed the database with initial data:
npm run seedEnvironment variables should be set up in both frontend and backend for seamless integration. Refer to the respective .env files for each setup.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License.