Skip to content

beef-noodles/node-server-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

API

It provides the RESTful API

Tech Stack

Node, Express, Vite, Prisma, TypeScript, Vitest, pre-commit, Docker

How to run

Using docker-compose to start service and database together, no need to set up the development environment in local

docker-compose up -d --build

How to develop

Using asdf / mise to manage all the runtime and tool version, which is defined in .tool-versions

Install Dependencies

asdf install
pnpm install

Start Database

docker-compose up -d postgis

Start Service

pnpm run dev

Verify Service

# Request the Health Check API
curl -i -X GET \
   -H "X-User-Role:Contributor" \
   -H "X-User-Name:name" \
 'http://localhost:3000/api/v1/health'

# Output should like {"status":"Running","dateTime":"2024-08-13T11:18:11+08:00"}

Database Migration

Using Prisma's Model/Entity-first migration pattern to generate / manage migrations like below flow:

Model/Entity-first migration

Generate the migration

# Running below command after you have updated the model definition in ./prisma/schema.prisma
pnpm run db:generate

Apply the migration

# Instead of restarting the service, we can deploy the migration manually here
pnpm run db:deploy

Testing

Note: If you have the issue to run repository tests in you terminal or other place

Please find the command and details according to your container runtime ref to this article

About

node koa server demo

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published