当前位置: 首页 > 软件库 > 数据库相关 > >

ws-node-demo

授权协议 Readme
开发语言 TypeScript
所属分类 数据库相关
软件类型 开源软件
地区 不详
投 递 者 施越彬
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

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 expressedin 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 processinglogic 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", whiledatabase 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 thoseresource with simple conditional logic.

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

ws-dev-docker-example : is the repository used to bundle thisapplication 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 productionready seed.

Although the application is best understood as a part of the larger overall effort demonstrated with thews-dev-docker-example, it can still be cloned and stood upwithout the use of the Docker bundle. To use this application as a separate standalone entity, use thelocal-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 outline21 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": "zip-zap@ez.com",
    "admin": false,
    "isLoggedIn": false
  }


  correct user
  {
    "username": "taosing",
    "password": "password",
    "firstname": "fifty",
    "lastname": "cents",
    "email": "zip-zap@ez.com",
    "admin": false,
    "isLoggedIn": false
  }
  • 目的: 建立socket-io 长连接, 客户端实现监听用户添加操作,添加后服务端返回最新的数据给客户端,取代了查询+添加接口,代码分为server和client端,如下所示: server端 const express = require('express'); // const cors = require('cors'); const { db } = require('../../Serv

  • WebSocket 介绍 WebSocket 是一种协议,2008年被首次提出,2011年被广泛应用,并且大部分浏览器均支持此协议。 WebSocket 是一种在单个 TCP 连接上进行全双工通信的协议。其实现了服务器和浏览器之间互相通信功能,在WebSocket 出现之前,解决实时获取服务端信息,一般使用 轮询 或者 长轮询 方案。这两种方案 无疑都造成了 服务器压力,WebSocket 就是为

  • 什么是fs(文件系统) file system 在Node中,与文件的交互是非常重要的,服务器的本质就是将本地的文件发送给远程的客户端 Node通过fs模块来和文件系统进行交互 该模块提供了一些标准文件访问API来打开,读取,写入文件,以及其他的交互 Node中使用fs模块,const fs = require('fs') fs中的同步和异步 fs模块中的所有操作都有两种操作形式,即同步和异步 同

  • 上一篇文章介绍了在浏览器端以中间件,路由,跨进程事件的姿势使用原生WebSocket。这篇文章将介绍如何使用Node.js以相同的编程模式来实现WebSocket服务端。 Node.js中比较流行的两个WebSocket库分别是socket.io与ws。其中socket.io已经实现了跨进程事件,广播,群发等功能,并且服务端与浏览器端是配套的,在不支持WebSocket技术的浏览器会降级为使用aj

  • websocket是html5提供的一种在单个tcp连接上进行全双工通讯的协议 websoket使得客户端和服务端的数据交换变的更加的简单。允许服务端主动向客户端推送数据,在websoket api中,浏览器和服务器值需要做一个握手的动作,然后浏览器和服务器之间就形成了一条快速通道。两者之间就直接可以数据相互传送。 websoket能更好的节省服务器资源和宽带,并且能够更实时地进行通讯。 浏览器通

  • 客户端 var ws; let isconnected = false; function reconnect() { ws = new WebSocket('ws://124.222.15.231:8001'); ws.onopen = function (e) { isconnected = true; console.log("连接服务器成

  • 报错原因很多时候时因为下载的版本和自己使用的版本不一致导致的, 到node-modules里面,找到node-sass文件,删除之后,重新在命令行里输入cnpm install node-sass,然后再cnpm run dev就可以正常启动了

 相关资料
  • ws-http 是一个简单轻量的HTTP 客户端工具库。可用于 HTTP API 测试,支持 ssl,basic auth,代理,自定义请求头,以及常用HTTP 请求方法。 $httpRequest = \Ws\Http\Request::create();$httpResponse = $httpRequest->get("https://api.github.com");$watcher = 

  • 实现基于Websocket 协议的 PHP类库 和 javascript类库 , 实现事件+回调函数的架构开发,以一个简单聊天室实例介绍其使用方法: 不同浏览器,不同电脑,不同地域, 实时通讯。实现的详细 请研究源码。 /***服务端****/ /**  * 实例化  */ $io = new SocketIO('127.0.0.1',8000); /**  * 监听连接  */ $io->on(

  • Coherent, zero-dependency, lazy, simple, GraphQL over WebSocket Protocol compliant server and client. Use Server-sent events (SSE) instead? Check out graphql-sse! Getting started Install yarn add grap

  • WS-Policy 定义了一个简单 XML 结构,由 4 个不同元素和一对属性组成。根据 WS-Policy 解释,这些元素和属性提供一种方法来组织和合并任意复杂度的策略断言(policy assertions)。为了定义构成策略的真实断言,您需要使用特定扩展,比如 WS-SecurityPolicy,而不是 WS-Policy 本身。 为了方便起见,WS-Policy 定义了一个标准形式的策略表

  • JAX-WS (JavaTM API for XML-Based Web Services)规范是一组XML web services的JAVA API。JAX-WS允许开发者可以选择RPC-oriented或者message-oriented 来实现自己的web services。 在 JAX-WS中,一个远程调用可以转换为一个基于XML的协议例如SOAP。在使用JAX-WS过程中,开发者不需要

  • 问题内容: 我构建了一个最小的Web服务,并使用javax.xml.ws.Endpoint发布了它。如果我尝试获得WSDL, 它就可以正常工作。 尝试在接收它,我什么也没收到。该地址与本地主机相同。 是否可以在不提供地址的情况下发布网络服务? 将代码更改为 在IP地址上获取wsdl,但不在本地主机上获取。 是否没有可能仅定义端口? 问题答案: 您可以尝试在0.0.0.0上发布它吗?