This project demonstrates a simple Node.js backend written in TypeScript. It exposes a few REST endpoints that use both MongoDB (via Mongoose) and PostgreSQL (via Prisma).
The repository includes a Dockerfile and a docker-compose.yaml to run the service together with MongoDB and PostgreSQL containers. It can also be executed directly with Node locally.
- Express based API server
- MongoDB integration using Mongoose
- PostgreSQL integration using Prisma ORM
- Dockerfile for containerisation
- Docker Compose configuration for local development with MongoDB and PostgreSQL
| Method | Endpoint | Description |
|---|---|---|
GET |
/ |
Health check route |
GET |
/mongo-register |
Registers a sample user in MongoDB |
GET |
/mongo-data |
Retrieves all users stored in MongoDB |
GET |
/prisma-register |
Registers a sample user in PostgreSQL |
GET |
/prisma-data |
Retrieves all users stored in PostgreSQL |
- Install dependencies
npm install
- Create an
.envfile with the following values (adjust if required):PORT=3000 MONGOSE_URL=mongodb://localhost:27017/my-data DATABASE_URL=postgres://myuser:mypass@localhost:5432/mydatabase
- Build and start the server
npm run dev
To launch the server together with MongoDB and PostgreSQL containers, run:
docker-compose up --buildWhen started via compose, the application will be available on http://localhost:3000.
npm run build– Compile the TypeScript sourcenpm start– Start the compiled JavaScript fromdist/npm run dev– Build then start the servernpm run docker-dev– Used within the Docker container to run migrations, build and startnpm test– Currently prints a placeholder message
This project is provided under the ISC license.