A RESTful API starter project for a social media application using Express.js, Sequelize ORM, and PostgreSQL.
- Express.js server setup with best practices
- Sequelize ORM integration with PostgreSQL
- User and Post models with relationships
- RESTful API endpoints for users and posts
- Like/unlike functionality
- Error handling middleware
- Environment variable configuration
- Docker and Docker Compose integration
├── app.js # Express app setup
├── package.json # Dependencies and scripts
├── .env # Environment variables
├── Dockerfile # Docker configuration
├── docker-compose.yml # Docker Compose configuration
├── public/ # Static assets
└── src/
├── index.js # Server entry point
├── config/ # Configuration files
├── controllers/ # Route controllers
├── migrations/ # Database migrations
├── models/ # Sequelize models
├── routes/ # API routes
└── seeders/ # Database seeders
- Node.js (v14+)
- PostgreSQL
- OR Docker and Docker Compose (recommended)
- Make sure Docker and Docker Compose are installed on your system
- Clone the repository
- Start the application and database containers:
docker-compose up -d
- Run database migrations within the container:
docker-compose exec api npm run db:migrate:dev
- The API will be available at http://localhost:3000
- Clone the repository
- Install dependencies:
npm install
- Configure your
.envfile with your database credentials - Run database migrations:
npm run db:migrate:dev
- Start the development server:
npm run start:dev
GET /api/users- Get all usersGET /api/users/:id- Get user by IDPOST /api/users- Create a new userPUT /api/users/:id- Update userDELETE /api/users/:id- Delete user
GET /api/posts- Get all postsGET /api/posts/:id- Get post by IDPOST /api/posts- Create a new postPUT /api/posts/:id- Update postDELETE /api/posts/:id- Delete postPOST /api/posts/:id/like- Like a postDELETE /api/posts/:id/like- Unlike a post
- Start containers:
docker-compose up -d - Stop containers:
docker-compose down - View logs:
docker-compose logs -f - Access container shell:
docker-compose exec api sh - Run migrations:
docker-compose exec api npm run db:migrate:dev
ISC