A Nodejs project template in Typescript to quickly have microservices built using graphql. Mongo db is used as database
All microservices are created under src/
. Example microservice - src/my-micro-service
- Copy directory my-micro-service into a new directory say
abc-micro-service
- Change the
name
field inpackage.json
underabc-micro-service
, toabc-micro-service
- In package.json of the main project, add this
abc-micro-service
as a local file dependency like"dependencies": { "abc-micro-service": "file:src/abc-micro-service", }
Graphql schemas are under api-schemas/config.json
Microservices are served under a specific path , say /graphql/my-micro-service
. For a microservice
to start up, register it under src/services/app.ts
import { MAPP as MICROSERVICE1 } from "my-micro-service";
app.use('/graphql/my-micro-service',
MICROSERVICE1);
npm install
npm start
this will start server at port 3092
Test your microservice(ex:my-micro-service
) in browser by hitting http://localhost:3092/my-micro-service