Skip to content

zoelabbb/rexpressapi.ts

Repository files navigation

rexpress REST API

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.

Tech Stack

  • 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.

Features

  1. Create Post: Allows the creation of new blog posts.

  2. Create User: Enables the creation of user accounts.

  3. Feed: Fetches a feed of blog posts, including author information.

  4. Delete Post: Allows the deletion of a specific blog post.

  5. Update Post: Enables the update of an existing blog post.

Getting Started

Follow these steps to set up and run the project on your local machine.

Prerequisites

Installation

  1. Clone the repository:

    git clone https://github.com/zoelabbb/rexpressapi.ts.git
  2. Navigate to the project directory:

    cd rexpressapi
  3. Install dependencies:

    npm install
    # or
    yarn install
  4. 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.

  5. Run the database migrations:

    npx prisma migrate dev init
  6. Compile the your project: (Optional)

    npx tsc
  7. Start the server:

    npm run dev
    # or
    node compile/index.ts

The API should now be running locally at http://localhost:3000.

API Endpoints

  • 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!

About

A simple and efficient REST API for managing blog posts and users. Built with Node.js, Express.js, TypeScript, and Prisma.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors