This repository contains the implementation of a User Microservice using TypeScript, Express, and Prisma (SQLite).
- REST API: Endpoints to manage users.
- GraphQL API: Flexible data querying.
- Swagger Documentation: Interactive API testing.
- Singleton Pattern: The application is managed via a Singleton
AppServer. - CORS Restricted: configured for
example.com.
- Node.js (v18+ recommended)
- npm
-
Clone the repository:
git clone <repository-url> cd <repository-folder>
-
Install dependencies:
npm install
This project uses an SQLite database. Initialize it with Prisma:
npx prisma db pushThis will create a dev.db file in the prisma directory.
Start the server:
npx ts-node src/index.tsThe server will start at http://localhost:3000.
- Get All Users:
GET http://localhost:3000/users - Get User by ID:
GET http://localhost:3000/users/:id
- Endpoint:
http://localhost:3000/graphql - Example Query:
{ users { id name } }
- Swagger UI:
http://localhost:3000/api-docs
src/index.ts: Application entry point and logic.prisma/schema.prisma: Database schema definition.