Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/tomdoestech/fastify-prisma-rest-api


https://github.com/tomdoestech/fastify-prisma-rest-api

authentication fastify nodejs prisma tutorial typescript

Last synced: 14 days ago
JSON representation

Awesome Lists containing this project

README

        

# Build a REST API with Fastify & Prisma

Video: https://youtu.be/LMoMHP44-xM

## What are we using?
* Fastify - Web server
* Prisma - Database ORM
* Zod - Request and response validation
* Swagger - API docs
* TypeScript - Types & other cool stuff

## What you will need
* [Postman](https://www.postman.com/) - Make API requests
* [Prisma studio](https://www.prisma.io/studio) - View data
* [PostreSQL or MySQL](https://github.com/tomanagle/awesome-docker-compose) - Database
* [Code editor](https://code.visualstudio.com/) - Edit your code

## Features
* Create a user
* Login
* List users
* Create a product
* List products
* Authentication
* Request & response validation
* Swagger docs

## Video structure
1. Demonstration
2. Code walk-through
3. Bootstrap application
* Setup Prisma
* Create Fastify instance
4. Create user
* Hash password
5. List users
6. Login
* fastify-jwt setup
7. Create product
8. List products

# Testing
## What are we testing with?
* [Node Tap](https://node-tap.org/) - Test framework
* [fastify.inject](https://www.fastify.io/docs/latest/Guides/Testing/#benefits-of-using-fastifyinject) - Inject HTTP requests
* [faker-js](@faker-js/faker) - Generate test data
* [ts-mock-imports](https://www.npmjs.com/package/ts-mock-imports) - Mock imports

## What will I learn?
* How to test your API end-to-end
* How to inject http requests to your Fastify application
* How to mock function calls
* How to test with a test database

## Where can I learn more about testing Fastify?
* [Unit Test Patterns And Strategies](https://github.com/knockaway/unit-test-patterns-and-strategies)
* [Node Tap documentation](https://node-tap.org/docs/getting-started/)
* [Fastify documentation](https://www.fastify.io/docs/latest/Guides/Testing/)