This repository contains a simple REST API for managing blog-related functionalities, including creating posts, creating users, fetching a feed of posts, deleting posts, and updating posts. This API is built using Node.js, Express, Prisma, and TypeScript] for database interactions I'am using PostgreSQL fl0.
- Node.js: A runtime environment for executing JavaScript code server-side.
- Express.js: A fast and minimalist web framework for Node.js.
- TypeScript: A typed superset of JavaScript that adds static types for better code quality.
- Prisma: An open-source database toolkit for Node.js and TypeScript.
-
Create Post: Allows the creation of new blog posts.
-
Create User: Enables the creation of user accounts.
-
Feed: Fetches a feed of blog posts, including author information.
-
Delete Post: Allows the deletion of a specific blog post.
-
Update Post: Enables the update of an existing blog post.
Follow these steps to set up and run the project on your local machine.
-
Clone the repository:
git clone https://github.com/zoelabbb/rexpressapi.ts.git
-
Navigate to the project directory:
cd rexpressapi
-
Install dependencies:
npm install # or yarn install
-
Set up your database connection in the
.env
file:DATABASE_URL="your-database-url"
Replace
"your-database-url"
with the actual URL of your database, in this case I'm using PostgreSQL by fl0. -
Run the database migrations:
npx prisma migrate dev init
-
Compile the your project: (Optional)
npx tsc
-
Start the server:
npm run dev # or node compile/index.ts
The API should now be running locally at http://localhost:3000.
- Get All Feed:
GET /feed
- Create New Post:
POST /posts
- Get Data Post by Id:
GET /posts/:postId
- Update Data Post by Id:
GET /posts/:postId
- Delete Data Post by Id:
GET /posts/:postId
- Create New User:
POST /users
- Get Username users:
GET /:username
Feel free to customize and extend the API based on your specific requirements!