Git Product home page Git Product logo

willstreeter / ws-node-demo Goto Github PK

View Code? Open in Web Editor NEW
33.0 6.0 18.0 1.12 MB

A NodeJs application written in TypeScript using ExpressJs framework to create a RESTful api for User model data stored in MongoDB using Mongoose as an adapter. Using the tsoa tool to facilitate a Swagger UI browser API test portal.

Makefile 1.95% TypeScript 98.05%
typescript nodejs tsoa swagger-ui expressjs mongoose mongodb jsonwebtoken

ws-node-demo's Introduction

ws-node-demo

A NodeJs application written in TypeScript using ExpressJs, Mongoose, and tsoa to stand up the Swagger UI.

Prominent Libraries used:

Architecture:

The article Swagger, NodeJS, & TypeScript : TSOA, has a deeper review of how this application is constructed. This back-end application is a part of a larger effort to demonstrate the principals of web development expressed in the article Practical Web Development and Architecture. Advocating the principal "a separation of concerns", thin controllers residing in the "service-layer" retain the singular purpose of acting as filters for API request. Controllers exist to support results of data processing logic derived in outside layers of concern. Maximizing the opportunity for application growth, without extensive refactoring, the processing of business rules and cross-cutting concerns are placed in the "business-layer", while database adapters, formalized data base queries, and services used to abstract those queries are stationed in the "data-layer". As much as possible the controllers duties are focused on directing request to outside resources and responding to results from those resource with simple conditional logic.

Another aspect emphasized in the Practical Web Development and Architecture article is the importance of adopting strategies to support optimal output from a development team. To this end tsoa, a Swagger UI creation tool, is used to demonstrate an innovative means of generating an API testing portal and documentation based on a few simple structural requirements. The Swagger scaffolding resides in the "presentation-layer" .

ws-dev-docker-example : is the repository used to bundle this application along with three other submodules. Docker compose is used to orchestrate the development of a FullStack. Those submodules are located in the GitHub repositories listed below.

How these containers are used as a bundle to facilitate a FullStack approach for developing with Docker is delineated in the article, Docker is my {I.D.E}

It should be noted that this application is created for the purposes of demonstrating a development paradigm, not as a production ready seed.

Although the application is best understood as a part of the larger overall effort demonstrated with the ws-dev-docker-example, it can still be cloned and stood up without the use of the Docker bundle. To use this application as a separate standalone entity, use the local-client branch.

Ways to construct this application with or without Docker

  1. Using the FullStack( This NodeJs app, Mongo, NGINX, Angular app ) approach with an integrated Docker environment.

  2. Using Docker to stand up the application with a dependency of Mongo


   $> git fetch

   $> git checkout origin/serverless

   $> docker-compose up

  1. BareMetal (Installing libraries and running it on your machine's OS)


   $> git fetch

   $> git checkout origin/local-client

   $> npm install

Befor running the application, you will need to update the src/data-layer/adapters/MongooseAccess.ts file by switching commented outline 21 and 22.

from

 //let connectionString =   config.get('mongo.urlClient').toString();
  let connectionString = config.get('mongo.urlDocker').toString();

to

   let connectionString =   config.get('mongo.urlClient').toString();
  //let connectionString = config.get('mongo.urlDocker').toString();

Making this change will switch the host from ws-mongo-demo to 127.0.0.1 (localhost). These variables are set in the config/default.yaml

   $> npm run start

Here are some examples of object types to insert an incorrect user and a correct user


  {
    "username": "tao",
    "password": "1234",
    "firstname": "zip",
    "lastname": "zap",
    "email": "[email protected]",
    "admin": false,
    "isLoggedIn": false
  }


  correct user
  {
    "username": "taosing",
    "password": "password",
    "firstname": "fifty",
    "lastname": "cents",
    "email": "[email protected]",
    "admin": false,
    "isLoggedIn": false
  }

ws-node-demo's People

Contributors

obowill avatar willsonic avatar

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

ws-node-demo's Issues

Cannot find module '/home/ws-node-demo/dist/server.js

Hi,

I'm getting below error after runing npm run start

[email protected] start:simple /home/ws-node-demo
node ./dist/server.js

module.js:538
throw err;
^

Error: Cannot find module '/home/ws-node-demo/dist/server.js'
at Function.Module._resolveFilename (module.js:536:15)
at Function.Module._load (module.js:466:25)
at Function.Module.runMain (module.js:676:10)
at startup (bootstrap_node.js:187:16)
at bootstrap_node.js:608:3
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start:simple: node ./dist/server.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start:simple script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
ERROR: "start:simple" exited with 1.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: npm-run-all -s clean build start:simple
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:

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.