← All projects

clean-rest-apis

by @ipenywis

118

Best Practices to write clean RESTFUL APIs using Node.js and Express

About this project

REST API Example This example shows how to implement a REST API with TypeScript using Express and Prisma Client. The example uses an SQLite database file with some initial dummy data which you can find at ./prisma/dev.db. Getting started Download example and install dependencies Download this example: Install npm dependencies: Alternative: Clone the entire repo Clone this repository: Install npm dependencies: Create and seed the database Run the following command to create your SQLite database file. This also creates the User and Post tables that are defined in prisma/schema.prisma: When npx prisma migrate dev is executed against a newly created database, seeding is also triggered. The seed file in prisma/seed.ts will be executed and your database will be populated with the sample data. Start the REST API server The server is now running on http://localhost:3000. You can now run the API requests, e.g. http://localhost:3000/feed. Using the REST API You can access the REST API of the server using the following endpoints: GET /post/:id: Fetch a single post by its id /feed?searchString={searchString}&take={take}&skip={skip}&orderBy={orderBy}: Fetch all published posts

From the project README on GitHub

Stars
118
Forks
32
Last push
27 Feb 2023

Add this badge to your README

Show that your project is listed on Made in Algeria.

Made in Algeria
[![Made in Algeria](https://www.madeinalgeria.dev/badge/clean-rest-apis.svg)](https://www.madeinalgeria.dev/projects/clean-rest-apis)

Related projects