A complete initial boilerplate for any WEB and MOBILE application to provide REST APIs, written in Node.js and ES6.
- /api/v1/register -For signUp.
- /api/v1/login -For logIn.
- /api/v1/logout -For logOut.
- /api/v1/resetPassword -For reset password.
- /api/v1/updatePassword -For update password.
6.All APIs can be seen in SWAGGER DOCS on http://localhost:5001/api-docs/
-
After starting the server in development mode swagger can be run with this url. http://localhost:5001/api-docs/
-
After adding any new API, need to update SWAGGER.js for that API.
To start any WEB or MOBILE application, we need complete package of REST APIs like signup/login/logout/resetPassword/UpdatePassword. This boilerplate can be used.
- Watcher and hot-reload: nodemon
- Build: babel
- tools: babel-cli, babel-core
- presets: babel-preset-es2015-node6, babel-preset-stage-3
- Deployment: PM2
- Tech Stack:
# install dependencies
npm install
# run for development with hot reload at localhost:5001
npm start
# build for production
npm run build
# run for production.
npm run serve
# run for test
npm run test
- Copy env file to .env
- Write necessary mailer service information.
# Install the Prisma CLI
brew install prisma
# Install Docker
To use Prisma locally, you need to have Docker installed on your machine. If you don\'t have Docker yet, you can download the Docker Community Edition for your operating system here.
https://www.docker.com/products/docker-engine
# Set up and connect Prisma with a database
mkdir hello-world
cd hello-world
# Create Docker Compose file
To launch Prisma on your machine, you need a Docker Compose file that configures Prisma and specifies the database it can connect to.
touch docker-compose.yml
# Add Prisma and database Docker images
Paste the following contents into the Docker Compose file you just created: for MongoDB
version: '3'
services:
prisma:
image: prismagraphql/prisma:1.30
restart: always
ports:
- "4466:4466"
environment:
PRISMA_CONFIG: |
port: 4466
databases:
default:
connector: mongo
uri: mongodb://prisma:prisma@mongo
mongo:
image: mongo:3.6
restart: always
environment:
MONGO_INITDB_ROOT_USERNAME: prisma
MONGO_INITDB_ROOT_PASSWORD: prisma
ports:
- "27017:27017"
volumes:
- mongo:/var/lib/mongo
volumes:
mongo:
# Launch Prisma and the connected database
docker-compose up -d
To bootstrap the configuration files for your Prisma client run the following command: prisma init --endpoint http://localhost:4466 The endpoint needs to match the URL of a running Prisma server.
The prisma init command created the minimal setup needed to deploy the Prisma datamodel: prisma.yml and datamodel.prisma. prisma deploy
If you want to view and edit the data in your database, you can use Prisma Admin. To access Prisma Admin, you need to append /_admin to your Prisma endpoint, for example: http://localhost:4466/_admin.
The Prisma client is a custom, auto-generated library that connects to your Prisma API. Append the following lines to the end of your prisma.yml: prisma generate
prisma init hello-world
- This launches an interactive wizard. Here's what you need to do:
- Select Use existing database
- Select your database, either PostgreSQL or MongoDB
- Provide the connection details for your database (see below for more info)
- Select the Prisma JavaScript client
cd hello-world
docker-compose up -d
prisma deploy
- Update databasemodel.prisma
- docker-compose up -d (Start server if not started)
- prisma deploy
- prisma generate (To generate prisma client plug in)