Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/kang-theo/beautiful-todos-server

Server-side of a decoupled frontend and backend project based on Node.js, Express, TypeScript, MVC, Prisma ORM, MySQL, etc.
https://github.com/kang-theo/beautiful-todos-server

express jest mvc-architecture mysql nodejs prisma swagger typescript zod

Last synced: 3 days ago
JSON representation

Server-side of a decoupled frontend and backend project based on Node.js, Express, TypeScript, MVC, Prisma ORM, MySQL, etc.

Awesome Lists containing this project

README

        

# Beautiful TODOs API Server

## Features

- ✔ Express framework
- ✔ MVC architecture
- ✔ TypeScript support
- ✔ Prisma ORM (MySQL)
- ✔ Customize error, log and catch all error
- Swagger document support
- Zod schema validation
- Rate limit
- Schema validation with zod
- Jest unit test

## How to run?

### Setup

Pull the code and create `.env` in server root directory, the content likes below

```.env
DATABASE_URL="mysql://{username}:{password}@localhost:3306/beautiful-todos?connection_limit=5"
```

If you use Postgres, please change the connection link

### Install

Enter the server directory and execute the below command

```bash
npm install
```

### Run the application

Enter the server directory and execute the below command

```bash
npm start
```

# Initialize the project from scratch

## NPM, Typescript and Express

* npm init -y
* npm install express
* npm i -D typescript ts-node nodemon @types/node @types/express
* npx tsc --init
* touch index.ts

## Prisma

* npm install -D prisma
* npm install prisma-client | npx prisma generate
* npx prisma db push: Outside prisma migration system)
* npx prisma migrate dev --name : After updating the Prisma schema, generate a new migration
* npx prisma migrate deploy: Apply the generated migration to bring your database schema in sync
* npx prisma migrate dev: Check if the drift issue persists
* npx prisma generate: Regenerate the Prisma Client to reflect the changes in your schema