A full-stack web application built to understand the fundamentals of RESTful architecture, CRUD operations, and server-side rendering. This project simulates a simple social media platform where users can create, read, update, delete, and search posts.
- Full CRUD Operations: Create, Read, Update, and Delete posts seamlessly.
- Search Functionality: Filter posts by username for easy discovery.
- Timestamps: Display real-time creation dates for posts.
- Unique IDs: Secure post identification using UUID.
- RESTful Routes: Follow standard API design patterns for clean and intuitive endpoints.
- Responsive UI: Styled with CSS for a user-friendly interface.
- Backend: Node.js, Express.js
- Frontend: EJS (Embedded JavaScript templates), CSS
- Tools: Method-Override, UUID, Path, Date-fns
- Node.js (version 14 or higher)
- npm (Node Package Manager)
-
Clone the repository:
git clone <your-repository-link> cd rest-class
-
Install dependencies:
npm install
Start the server:
node index.jsThe application will be running at http://localhost:3000.
Navigate to http://localhost:3000/posts to view and interact with posts.
- View Posts: Visit the home page to see all posts.
- Create Post: Click "Create new post" to add a new entry.
- Edit Post: Use the "Edit" link on any post to modify it.
- Delete Post: Click "Delete" to remove a post.
- Search: Use the search bar to filter posts by username.
| Method | Endpoint | Description |
|---|---|---|
| GET | /posts |
Get all posts |
| GET | /posts/new |
Show create post form |
| POST | /posts |
Create a new post |
| GET | /posts/:id |
Get a specific post |
| PATCH | /posts/:id |
Update a specific post |
| GET | /posts/:id/edit |
Show edit post form |
| DELETE | /posts/:id |
Delete a specific post |
| GET | /search |
Search posts by username |
rest-class/
├── index.js # Main application file
├── package.json # Dependencies and scripts
├── README.MD # Project documentation
├── public/ # Static assets (CSS, images)
│ └── style.css
├── views/ # EJS templates
│ ├── index.ejs
│ ├── show.ejs
│ ├── edit.ejs
│ ├── form.ejs
│ └── includes/
│ └── head.ejs
└── notes/ # Additional notes (not part of app)
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the ISC License.
Tariq Hussain