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.local
file:NEXT_PUBLIC_API_URL=<your_backend_api_url>
To start the development server:
npm run dev
or with yarn:
yarn dev
To create an optimized production build:
npm run build
To start the production server:
npm start
or 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.local
and.env.prod
files 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 dev
To start the production server:
npm run start
To generate a new migration:
npm run typeorm:generate -- NameOfMigration
To run migrations:
npm run typeorm:migrate
To revert the last migration:
npm run typeorm:revert
To drop the database schema:
npm run typeorm:drop
To seed the database with initial data:
npm run seed
Environment 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.