Coder Social home page Coder Social logo

khriztianmoreno / nodejs-scaffolding Goto Github PK

View Code? Open in Web Editor NEW
34.0 5.0 17.0 103 KB

A node.js sample application that demonstrates an architecture for building a complete production API with Node.JS, Express.JS and MongoDB

License: MIT License

JavaScript 65.47% HTML 34.53%
nodejs nodejs-mongodb expressjs mongodb mongoose api scaffolding

nodejs-scaffolding's Introduction

Node.JS - Scaffolding API

All Contributors PRs Welcome

Hello, and welcome! This Node.JS sample application that demonstrates an architecture for building a complete production API with Node.JS, Express.JS and MongoDB It features an architectural demonstration of these features:

  • Built with Node.js and Express
  • REST API with authentication scheme

Express Router and Routes

Route HTTP Verb Route Middleware Description
/api/users GET Get list of users
/api/users POST Creates a new user
/api/users/:id GET isAuthenticated Get a single user
/api/users/:id DELETE hasRole('admin') Deletes a user, restriction: 'admin'
/api/users/me GET isAuthenticated Get my info
/api/users:id/password PUT isAuthenticated Change a users password

Usage

Basic example Create USER /api/users:

Request Body:

{
  "name": "CRISTIAN MORENO",
  "email": "[email protected]",
  "password": "my-secret-password"
}

Response:

{
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI1OWFiNzkyMWQ1Yzk3NjJlZGQzZmUwZDgiLCJpYXQiOjE1MDQ0MDk4ODksImV4cCI6MTUwNDQyNzg4OX0.2gZPXZ-dQc3kQ1fcIDryHm4gIqWLvcw6guAOnP0ueGU"
}

Getting Started

Prerequisites

Developing

  1. Run npm install to install server dependencies.

  2. Run mongod in a separate shell to keep an instance of the MongoDB Daemon running

  3. Run npm run dev to start the development server. It should automatically open the client in your browser when ready.

  4. Open browser http://localhost:3030/api/helloworld.

Contributors

Thanks goes to these wonderful people (emoji key):


Khriztian Moreno

๐Ÿ’ป ๐Ÿ“– ๐Ÿ’ก

This project follows the all-contributors specification. Contributions of any kind welcome!

nodejs-scaffolding's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

nodejs-scaffolding's Issues

expressJwt needs specified algorithm

Hey,

I had to modify auth.service.js to get this to run, adding algorithms: ['RS256'] to the expressJwt configuration.

There are also quite verbose warnings popping up at npm run dev complaining about mongodb settings (but that is probably because I updated it before running since npm informed me that the original mongo version included had severe security problems.

The useMongoClient option is no longer necessary in mongoose 5.x, please remove it.

I think this project seems quite helpful to someone learning about node backend stuff (like me) so I figured I'd comment about it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.