Simple Node jS gRPC Server with Mongo DB
Node JS GRPC Server with Express JS REST client using Mongo DB as database.
Make sure you have at least Node.js 10.16.0 installed.
You can check your Node.js version by running node -v:
$ node -v
v10.16.0
clone
Navigate to your work directory and clone the project, change directory to the node-grpc
and add a new remote origin pointing to the new project repo.
$ git clone https://github.com/akinmaurice/node-grpc.git
$ cd node-grpc
env
You can set environment variables using .env
file, or setting them in your .bashrc
or .zshrc
file.
.env
:
$ touch .env
# using any editor you prefer. (vim/nano/vi).
$ vim .env
Paste the following configuration variables with their corresponding values.
DATABASE_URI=VALUE
.bashrc
or .zshrc
:
# open your bashrc or zshrc file,
# using any editor you prefer. (vim/nano/vi).
$ vim ~/.bashrc
Paste the following configuration variables with their corresponding values.
DATABASE_URI=VALUE
Run command to reload
$ source ~/.bashrc
Run command to install dependencies
$ npm install
Run command to start server on port 50051
$ npm run start-server
open a new terminal and run command to start client on port 3000
$ npm run start-client
The above will get you a copy of the project up and running on your local machine for development and testing purposes.
GET {{ base_uri }}/api/todos
{
"todos": [
{
"id": "215782",
"title": "Test Todo",
"completed": false
},
{
"id": "380484",
"title": "Running Man Todo",
"completed": false
},
{
"id": "541088",
"title": "Watch football",
"completed": false
}
]
}
GET {{ base_uri }}/api/todos/:id
{
"id": "609871",
"title": "Test Todo",
"completed": false
}
POST {{ base_uri }}/api/todos
parameters | Type | Description |
---|---|---|
title | string | Todo Title |
{
"id": "215782",
"title": "Test Todo",
"completed": false
}
DELETE {{ base_uri }}/api/todos/:id
{
"status": "true"
}
This project is licensed under the MIT License - see the LICENSE.md file for details