ws-node-demo

我要开发同款
匿名用户2021年12月10日
72阅读
开发技术TypeScript
所属分类数据库相关
授权协议Readme

作品详情

ws-node-demoANodeJsapplicationwritteninTypeScriptusingExpressJs,Mongoose,andtsoatostanduptheSwaggerUI.ProminentLibrariesused:ExpressmongooseJWTtsoaArchitecture:

ThearticleSwagger,NodeJS,&TypeScript:TSOA,hasadeeperreviewofhowthisapplicationisconstructed.Thisback-endapplicationisapartofalargerefforttodemonstratetheprincipalsofwebdevelopmentexpressedinthearticlePracticalWebDevelopmentandArchitecture.Advocatingtheprincipal"aseparationofconcerns",thincontrollersresidinginthe"service-layer"retainthesingularpurposeofactingasfiltersforAPIrequest.Controllersexisttosupportresultsofdataprocessinglogicderivedinoutsidelayersofconcern.Maximizingtheopportunityforapplicationgrowth,withoutextensiverefactoring,theprocessingofbusinessrulesandcross-cuttingconcernsareplacedinthe"business-layer",whiledatabaseadapters,formalizeddatabasequeries,andservicesusedtoabstractthosequeriesarestationedinthe"data-layer".Asmuchaspossiblethecontrollersdutiesarefocusedondirectingrequesttooutsideresourcesandrespondingtoresultsfromthoseresourcewithsimpleconditionallogic.

AnotheraspectemphasizedinthePracticalWebDevelopmentandArchitecturearticleistheimportanceofadoptingstrategiestosupportoptimaloutputfromadevelopmentteam.Tothisendtsoa,aSwaggerUIcreationtool,isusedtodemonstrateaninnovativemeansofgeneratinganAPItestingportalanddocumentationbasedonafewsimplestructuralrequirements.TheSwaggerscaffoldingresidesinthe"presentation-layer".

ws-dev-docker-example:istherepositoryusedtobundlethisapplicationalongwiththreeothersubmodules.DockercomposeisusedtoorchestratethedevelopmentofaFullStack.ThosesubmodulesarelocatedintheGitHubrepositorieslistedbelow.

(thisrepo)ws-node-demows-mongo-demows-nginx-demows-ngx-login-demo

HowthesecontainersareusedasabundletofacilitateaFullStackapproachfordevelopingwithDockerisdelineatedinthearticle,Dockerismy{I.D.E}

Itshouldbenotedthatthisapplicationiscreatedforthepurposesofdemonstratingadevelopmentparadigm,notasaproductionreadyseed.

Althoughtheapplicationisbestunderstoodasapartofthelargeroveralleffortdemonstratedwiththews-dev-docker-example,itcanstillbeclonedandstoodupwithouttheuseoftheDockerbundle.Tousethisapplicationasaseparatestandaloneentity,usethelocal-clientbranch.

WaystoconstructthisapplicationwithorwithoutDocker

UsingtheFullStack(ThisNodeJsapp,Mongo,NGINX,Angularapp)approachwithanintegratedDockerenvironment.

Gotothews-dev-docker-examplerepoandfollowtheREADME.md

UsingDockertostanduptheapplicationwithadependencyofMongo

$>gitfetch$>gitcheckoutorigin/serverless$>docker-composeupSwaggerUIAPItesterhttps://localhost:8080/docs

BareMetal(Installinglibrariesandrunningitonyourmachine'sOS)

InstallMongoDBonyourmachine.MongoDBOSXEditionMongoDBWindowsEdition$>gitfetch$>gitcheckoutorigin/local-client$>npminstall

Beforrunningtheapplication,youwillneedtoupdatethesrc/data-layer/adapters/MongooseAccess.tsfilebyswitchingcommentedoutline21and22.

from

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

to

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

Makingthischangewillswitchthehostfromws-mongo-demoto127.0.0.1(localhost).Thesevariablesaresetintheconfig/default.yaml

$>npmrunstartSwaggerUIAPItesterhttps://localhost:8080/docsHerearesomeexamplesofobjecttypestoinsertanincorrectuserandacorrectuser{"username":"tao","password":"1234","firstname":"zip","lastname":"zap","email":"zip-zap@ez.com","admin":false,"isLoggedIn":false}correctuser{"username":"taosing","password":"password","firstname":"fifty","lastname":"cents","email":"zip-zap@ez.com","admin":false,"isLoggedIn":false}
声明:本文仅代表作者观点,不代表本站立场。如果侵犯到您的合法权益,请联系我们删除侵权资源!如果遇到资源链接失效,请您通过评论或工单的方式通知管理员。未经允许,不得转载,本站所有资源文章禁止商业使用运营!
下载安装【程序员客栈】APP
实时对接需求、及时收发消息、丰富的开放项目需求、随时随地查看项目状态

评论