Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/akunna1/api-mysql-node-express

Creating an API using MySQL, Express.js, and Node.js to create a social media post with CRUD operations. The post includes a message and an image upload
https://github.com/akunna1/api-mysql-node-express

crud-api database express-js multer mysql node-js

Last synced: about 1 month ago
JSON representation

Creating an API using MySQL, Express.js, and Node.js to create a social media post with CRUD operations. The post includes a message and an image upload

Awesome Lists containing this project

README

        

- Create a database and a posts table with fields for the id, message, and image_url to store post details...

#### Steps
- Install Required Packages: npm init -y, npm install express mysql multer body-parser
- Creating the posts table:

CREATE DATABASE social_media_db;

USE social_media_db;

CREATE TABLE posts (
id INT AUTO_INCREMENT PRIMARY KEY,
message VARCHAR(255) NOT NULL,
image_url VARCHAR(255)
);

#### API Endpoints (index.js)
- Create Post (with image): POST /posts (Form-data: message, image)
- Get All Posts: GET /posts
- Get Single Post: GET /posts/:id
- Update Post (with new image): PUT /posts/:id (Form-data: message, image)
- Delete Post: DELETE /posts/:id