Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/19eb/microservices-base
Nodejs project on microservices
https://github.com/19eb/microservices-base
api architecture backend backend-api express expressjs gateway-api microservice microservices microservices-architecture node node-js node-js-express nodejs rest rest-api restful restful-api typescript
Last synced: 2 days ago
JSON representation
Nodejs project on microservices
- Host: GitHub
- URL: https://github.com/19eb/microservices-base
- Owner: 19EB
- License: mit
- Created: 2022-12-06T09:23:12.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2022-12-09T08:00:51.000Z (almost 2 years ago)
- Last Synced: 2024-03-22T10:29:47.552Z (8 months ago)
- Topics: api, architecture, backend, backend-api, express, expressjs, gateway-api, microservice, microservices, microservices-architecture, node, node-js, node-js-express, nodejs, rest, rest-api, restful, restful-api, typescript
- Language: TypeScript
- Homepage:
- Size: 43.9 KB
- Stars: 4
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# microservices-base
Basic microservices project that includes a gateway (api-gateway) and 3 microservices (user/product/client)
This is just my personal project experimenting how the architecture works.
### Prerequisites
- Install [Node.js](https://nodejs.org/en/)
### Installing
- Clone the repository
```
git clone https://github.com/19EB/microservices-base
```
- Install dependencies on api-gateway
```
cd api-gateway
npm install
```
- Install dependencies on each microservice (user, product and client)
```cd services/
npm install
```
### Environment variables
This project uses the following environment variables:
##### api-gateway
```
# Port
PORT=8000
# User service
USER_SERVICE_URL='http://localhost:8001'
# Client service
CLIENT_SERVICE_URL='http://localhost:8002'
# Product service
PRODUCT_SERVICE_URL='http://localhost:8003'
```##### user
```
# Database
DB=''
# Service port
PORT=8001
# Other services
CLIENT_SERVICE_URL='http://localhost:8002'
PRODUCT_SERVICE_URL='http://localhost:8003'
```
##### client
```
# Database
DB=''
# Service port
PORT=8002
# Other services
USER_SERVICE_URL='http://localhost:8001'
PRODUCT_SERVICE_URL='http://localhost:8003'
```
##### product
```
# Database
DB=''
# Service port
PORT=8003
# Other services
USER_SERVICE_URL='http://localhost:8001'
CLIENT_SERVICE_URL='http://localhost:8002'
```### Running the project
- Start each microservice from its own directory
Development mode
```
cd services/npm run dev
```
Production mode
```
cd services/npm start
```- Start the api-gateway
```
cd api-gatewaynpm start
or
npm run dev
```
Navigate to `http://localhost:8000`### Endpoints
The project has couple endpoints to ping each other and one normal endpoint.
`http://localhost:8000/user/list`
`http://localhost:8000/user/ping-client`
`http://localhost:8000/user/ping-product`
`http://localhost:8000/client/list`
`http://localhost:8000/client/ping-user`
`http://localhost:8000/client/ping-product`
`http://localhost:8000/product/list`
`http://localhost:8000/product/ping-user`
`http://localhost:8000/product/ping-client`
## License
This project is licensed under the MIT License