TSOA-Sandbox
January 17, 2018 ยท View on GitHub
A personal project utilizing TSOA with Node, Express and MongoDB for the Server; Angular 5 for the Client.
Progress
- (Latest) I haven't made much progress over the last couple of days. All the commits were testing Heroku and Service Worker. Fetching data wise, I have been able to fetched the right data for the User (using their JWT issued on
successfully login). - (Jan 13 2018) Deployed to Heroku as-is. Going to implement more on the Client-side when I've got time to work with it.
- (Jan 12 2018) Tested out the
ApiClientthat Swagger-Codegen generated. Everything worked out pretty well. I also initialized Angular-Redux from@angular-redux/store. This is going well so far. - (Jan 11 2018) Initialized Angular 5 Frontend. I also tried to include Angular's Service Worker in this project. Let's see how far we can go. Swagger-Codegen is also working as expected. Good day!!
- (Jan 10 2018) Finally got Passport integrated successfully. My routes can be protected with just one line of code (
@Security('JWT')). Going to implement the rest ofTaskControllerthen move on toFrontend. - (Jan 10 2018) I've made some changes to
UserControllerand finally got SwaggerUI integrated and working. The models are rendered fine. Next is to implement anotheractorinto the application then move on tofront-end. - (Jan 09 2018) What a rough day! I've been looking for a working AutoMapper for JS/TS but to no-avail. I've looked at Automapper-ts but the author explicitly said he didn't build the package for using Node specifically. I am going to rewrite my
UserControllertomorrow. - (Jan 08 2018) I've completed utilizing Repository Pattern for the controllers and successfully generated the
routes.tsfile for the backend. Next, I'm looking into injecting SwaggerUI into the project. TSOA, so far, has been working wonder for me. One of the roadblocks was I want to use 3rd party package likepassportJSto have protected route. However, theroutesare generated by TSOA. Hence, I had to create acustom-templatethat will injectpassport.authenticatemiddleware into theroutes.tstemplate. I haven't tested the result but will definitely have it tested in the next commit. - (Jan 06 2018) I was fascinated by the almighty Swagger (aka OpenAPI) and was really excited to discover
TSOApackage. As I am trying to integrate TypeScript with Node Express backend, I decide to start on a project withTSOA. A lot of roadblocks at first but eventually, I found solutions for most of them.
Steps to get the environment ready
- Install
nodemonglobally if haven't - Install
rimrafglobally if haven't - (Optional for generating Code for Angular front-end) Install
swagger-codegenif haven't. Visit: https://github.com/swagger-api/swagger-codegen - Clone the project.
- Read
config/default-example.yaml - Run
npm installon both the Server and Client side (angular-src)
Steps to start the project
- Run
npm run start-gen-devon project's root directory - Open a new terminal (still at the project's root), run
npm run swagger-client - Open your browser on:
localhost:8080/api/docsto check out the SwaggerUI Documentation - (Optional) If you want to run the
Angular front-end,cd ./angular-srcthenng serve
Technologies
- Node
- ExpressJS
- MongoDB
- TSOA
- TypeScript
- JWT
- PassportJS
- Various others