当前位置: 首页 > 软件库 > 大数据 > 数据查询 >

node-mongodb-graphql-starter

授权协议 GPL-3.0 License
开发语言 Java
所属分类 大数据、 数据查询
软件类型 开源软件
地区 不详
投 递 者 程鸿波
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

NodeJs + MongoDB + GraphQL Starter

NodeJs + MongoDB + GraphQL Starter

A boilerplate for Node.js, MongoDB & GraphQL applications.

�� ES6 code

I started this project to simplify and make it ease of use. I also tried to make it as generic and reusable as possible to cover most use cases of GraphQL apps, without being too specific.

Table of Contents

Features

  • Local Authentication using Email and Password
  • MVC Project Structure
  • GraphQL Mutations, Queries, Resolvers
  • Account Management
    • Register
    • Login
    • Update profile
    • Profile Details
    • Add user address
    • Update Address
    • Remove Address
  • Cron job scheduler
  • JSON Web Token (JWT) Sign in

Prerequisites

  • MongoDB
  • Node.js 6.0+
  • Command Line Tools
  •  Mac OS X: Xcode (or OS X 10.9+: xcode-select --install)
  •  Windows: Visual Studio
  •  Ubuntu /  Linux Mint: sudo apt-get install build-essential
  •  Fedora: sudo dnf groupinstall "Development Tools"
  •  OpenSUSE: sudo zypper install --type pattern devel_basis

Getting Started

The easiest way to get started is to clone the repository:

# Get the latest snapshot
git clone --depth=1 https://github.com/ailoitte/node-mongodb-graphql-starter.git myproject

# Change directory
cd myproject

# Install NPM dependencies
npm install

# Then simply start your app
node app.js

Note: I highly recommend installing Nodemon.It watches for any changes in your node.js app and automatically restarts theserver. Once installed, instead of node app.js use nodemon app.js. It willsave you a lot of time in the long run, because you won't need to manuallyrestart the server each time you make a small change in code. To install, runsudo npm install -g nodemon.

Packages

Package Description
async Utility library that provides asynchronous control flow.
bcrypt-nodejs Library for hashing and salting user passwords.
connect-mongo MongoDB session store for Express.
dotenv Loads environment variables from .env file.
express Node.js web framework.
body-parser Express 4 middleware.
morgan Express 4 middleware.
mongoose MongoDB ODM.
nodemailer Node.js library for sending emails.
request Simplified HTTP request library.
lodash Handy JavaScript utilities library.
validator Used in conjunction with express-validator.
jsonwebtoken An implementation of JSON Web Tokens.
mongoose-paginate MongoDB mongoose pagination
moment JS date library- parsing,validating,manipulating,andformatting dates.
mime Comprehensive MIME type mapping API based on mime-db module.
firebase-admin Push notification
aws-sdk AWS client SDK
multer-s3 Upload multipart to S3
winston async logging library
cron Cron job

Query & Mutation

ADD USER

mutation {
  addUser(name: "Sunil Kumar", email: "sunilkumar707@yahoo.in", mobileNumber:"8867371492", password: "123567"){
    id
    name
    email
    mobileNumber
  }
}

UPDATE

mutation {
  updateUser(name: "Ravi Sanker"){
    id
    name
    email
    mobileNumber
  }
}

LOGIN

mutation {
  loginUser(mobileNumber: "8867371492", password:"1234567") {
    id
    token
    name
    email
  }
}

ADD ADDRESS

mutation {
  addUserAddress(street: ["s1", "s2"], 
    city:"Dehradun", 
    countryId: "IN", 
    addressType: "home",
    postcode:"23455"
  ) {
    id
    street
    city
    countryId
    landmark
    locality
    addressType
    postcode
  }
}

UPDATE ADDRESS

mutation {
  updateUserAddress(id: "59e4d803d3528728b99b3c53",
    street: ["Nesh", "Indra Road"], 
    city:"Dehradun", 
    countryId: "IN", 
    addressType: "home",
    postcode:"234551"
  ) {
    id
    street
    city
    countryId
    landmark
    locality
    addressType
    postcode
  }
}

DELETE ADDRESS

mutation {
  deleteUserAddress(
   id: "59e4dc6b875e8829539b20d7"
  ){
    message
  }
}

ALL ADDRESS

query {
  me{
    address{
      street
      city
    }
  }
}

ADDRESS BY ID

query {
  userAddress(id: "59e4d803d3528728b99b3c53"){
    id
    city
    street
    countryId
  }
}
}
  • 一、初始化项目及安装一些包 1、官网克隆种子文件 $ git clone https://github.com/nestjs/typescript-starter.git project $ cd project $ npm install 2、安装graphql包及mongoose包(安装包后可能会报错,需要重新安装ts-node) $ npm install --save @nestjs/mo

 相关资料
  • GraphQL Server Boilerplates for Node.js Bootstrap your GraphQL server within seconds GraphQL boilerplates provide the perfect foundation for your GraphQL server, no matter if you're just getting start

  • graphql-to-mongodb If you want to grant your Nodejs GraphQL service a whole lot of the power of the MongoDb database standing behind it with very little hassle, you've come to the right place! Example

  • koa-graphql-mongodb is being sponsored by the following tool; please help to support us by taking a look and signing up to a free trial. koa-graphql-mongodb Tutorial how to set up koa with graphql and mongodb

  • GraphQL MongoDB Server A server boilerplate using GraphQL and MongoDB. Introduction This is a server boilerplate using GraphQL and MongoDB. Support subscriptions using GraphQL Yoga. Getting started Cl

  • Node.js Express API with TypeScript 4 Node.js Express API with TypeScript 4. Supports MongoDBSee node-express-fast-progress if you need vanilla JS Description This generator will help you to build you

  • Node.js Express & MongoDB: CRUD Rest APIs For more detail, please visit: Node.js, Express & MongoDb: Build a CRUD Rest Api example Server side Pagination in Node.js with MongoDB and Mongoose Security: