This is a full-stack application with a TypeScript Express backend and React TypeScript frontend.
Before you begin, ensure you have the following installed:
Required knowledge:
- Basic understanding of TypeScript
- Familiarity with React
- Understanding of Express.js
- Knowledge of RESTful APIs
IDE Requirements:
- VS Code (recommended) with the following extensions:
- ESLint
- Prettier (for code formatting)
- TypeScript support
backend/
- Express TypeScript backendfrontend/
- React TypeScript frontend
-
Navigate to the backend directory:
cd backend
-
Install dependencies:
npm install
-
Start the development server:
npm run dev
The backend will run on http://localhost:5000
-
Navigate to the frontend directory:
cd frontend
-
Install dependencies:
npm install
-
Start the development server:
npm start
The frontend will run on http://localhost:3000
- Backend: The TypeScript Express server is configured with hot-reloading using ts-node.
- Frontend: Create React App with TypeScript template provides hot-reloading out of the box.
npm run dev
- Start the development servernpm run build
- Build the TypeScript codenpm start
- Run the built codenpm run watch
- Run TypeScript compiler in watch mode
npm start
- Start the development servernpm test
- Run testsnpm run build
- Build for productionnpm run eject
- Eject from Create React App
Here's a chronological list of development steps and issues addressed:
-
Initial Setup
- Created a full-stack TypeScript application with React frontend and Express backend
- Set up basic project structure and dependencies
- Implemented basic API endpoint communication
-
Task Management Implementation
- Added Task interface and API endpoints for CRUD operations
- Implemented frontend components (TaskInput and TaskList)
- Set up proper TypeScript types
-
Troubleshooting & Fixes
- Fixed TypeScript module issues with types.ts
- Resolved backend server startup issues
- Added proper error handling and loading states
- Fixed task creation functionality
-
Features Implemented
- Add new tasks
- Display list of tasks
- Toggle task completion status
- Delete tasks
- Real-time error feedback
- Loading states for better UX
- Description: Retrieve all tasks
- Response: Array of Task objects
[
{
id: number,
title: string,
completed: boolean,
createdAt: Date
}
]
- Description: Create a new task
- Request Body:
{
title: string
}
- Response: Created Task object
- Description: Toggle task completion status
- Parameters:
- id: Task ID (number)
- Response: Updated Task object
- Description: Delete a task
- Parameters:
- id: Task ID (number)
- Response: 204 No Content
- Location:
frontend/src/components/TaskInput.tsx
- Props:
interface TaskInputProps {
onAddTask: (title: string) => Promise<void>;
}
- Description: A form component that allows users to add new tasks
- Features:
- Input validation (non-empty title)
- Clears input after successful submission
- Error handling for failed submissions
- Location:
frontend/src/components/TaskList.tsx
- Props:
interface TaskListProps {
tasks: Task[];
onToggleTask: (id: number) => Promise<void>;
onDeleteTask: (id: number) => Promise<void>;
}
- Description: Displays the list of tasks with toggle and delete functionality
- Features:
- Checkbox for task completion
- Delete button for task removal
- Visual indication of completed tasks
The application implements comprehensive error handling:
- Loading states during API calls
- User-friendly error messages
- Network error handling
- Form validation feedback
- Input validation
- Error status codes
- Error response messages
- CORS error handling
Location: frontend/src/types.ts
and backend/src/index.ts
interface Task {
id: number;
title: string;
completed: boolean;
createdAt: Date;
}
- TypeScript strict mode enabled
- React functional components with hooks
- Async/await for API calls
- Error boundaries for React components
- Proper TypeScript type definitions
- Consistent file and component naming
- CSS BEM naming convention for styles
To run tests:
cd frontend
npm test
cd backend
npm test
- Build the production bundle:
cd frontend
npm run build
- The build folder will contain optimized static files ready for deployment
- Build the TypeScript code:
cd backend
npm run build
- The dist folder will contain compiled JavaScript ready for deployment
This project is licensed under the MIT License - see the LICENSE file for details