pl-nhandan-souvenir-be
v1.0.1
Published
tRPC server for pl-nhandan-souvenir app with MongoDB integration
Readme
Nhandan Souvernir Backend
A tRPC server that connects to MongoDB for the Nhandan Souvernir application.
Tech Stack
- tRPC with Zod for type-safe API
- TypeScript
- Mongoose (MongoDB ODM)
- Standalone HTTP server
Setup
- Clone the repository
- Install dependencies:
npm install - Set up environment variables (optional):
- Create a
.envfile in the root directory - Add the MongoDB connection string:
MONGODB_URI=mongodb://username:password@host1:27017,host2:27017,host3:27017/nhandan-souvenir?authSource=admin&replicaSet=rs0 PORT=3033
- Create a
Development
Run the development server:
npm run devBuild and Start
Build the project:
npm run buildStart the production server:
npm startAPI Endpoints
The tRPC API exposes the following routers:
History Router
history.create- Create a new history recordhistory.getAll- Get all histories with pagination and filteringhistory.getById- Get a history record by IDhistory.update- Update a history recordhistory.delete- Delete a history record
Client Integration
To use this API in your client application, you can import the AppRouter type:
import type { AppRouter } from 'nhandan-souvernir-be';This will provide you with full type safety for your API calls.
License
ISC
