pltod2 / braggers Goto Github PK
View Code? Open in Web Editor NEWOne Project For The First Edition Of Axway's Node.js Training
License: MIT License
One Project For The First Edition Of Axway's Node.js Training
License: MIT License
This scenario explain one idea of introducing users into the system.
Get data from slack and GitHub, combine it and store it into users.json
In Admin Mode we will have a Button to start the process of importing users that are still not present...if the email exists the user will not be considered. The reason is that we do not want to override the already imported and augmented users.
Possible we could design command line tool to our system. This command line tool will be able to trigger similar operation but form the Terminal. Also it could start and stop process that do this in background so new users appear on the fly.
Integrate the code from app.js into web application that we have with webpack and react. In order to complete this the following must be done:
Move the web app code into your branch
Take your logic from app.js and put it into App.js react component into newly created function called componentDidMount. This is lifecycle method that react invokes after initial rendering of your component. See more here https://facebook.github.io/react/docs/react-component.html. To understand react in general look this short tutorial - https://facebook.github.io/react/tutorial/tutorial.html
When you collect all of your data call the setState with the data set into state property of your choice. This will cause the react to re-render the component with the provided data.
oAuth strategy
Command Line Interface with commands that will be used to demonstrate import and export of data. This will communicate directly with our API Server.
I would like to have passwordless login. Here is the thing:
We have users in the system with emails
Show form with only email input - when user enters valid email we will send email with confirmation link that will login this user into the system
I imagine this to be done with password less + stateless meaning to use something like JWT and not mongo or redis stores.
Sample links would be used to craft the solution:
https://blog.risingstack.com/node-hero-node-js-authentication-passport-js/
https://community.risingstack.com/zeromq-node-js-cracking-jwt-tokens-1/
https://community.risingstack.com/zeromq-node-js-cracking-jwt-tokens-part2/
https://github.com/florianheinemann/passwordless
protected and non-protected endpoints -> https://scotch.io/tutorials/authenticate-a-node-js-api-with-json-web-tokens
Here are the steps:
HINT: you can do the work for step 1 in a branch and submit PR after which you could do the step 2 in separate branch and submit PR. More granular work that cover single concern in PR is better.
Continue working in app.js. Take the data from Slack as it is now. Use the emails list to make request to Github in order to take the data for users by their email address. The data from Slack and Github should be merged into single User Profile Model and printed to the console.
You access GitHub in the same manner as other APIs services. You need token etc. .... More general info here: https://developer.github.com
Moreover you need SDK to consume the API. There are alternatives out there.
One example of mine using octonode (https://github.com/pksunkara/octonode) API wrapper that collect who the user is following is here - https://github.com/pltod/hb-nodejs-2014/tree/master/shared/api/facade-github-octonode
Alternatives to octonode wrapper are:
Integrate the code from app.js into web application that we have with webpack and react. In order to complete this the following must be done:
Move the web app code into your branch
Take your logic from app.js and put it into App.js react component into newly created function called componentDidMount. This is lifecycle method that react invokes after initial rendering of your component. See more here https://facebook.github.io/react/docs/react-component.html. To understand react in general look this short tutorial - https://facebook.github.io/react/tutorial/tutorial.html
When you collect all of your data call the setState with the data set into state property of your choice. This will cause the react to re-render the component with the provided data.
How to integrate it:
https://facebook.github.io/draft-js/
https://github.com/brijeshb42/medium-draft
This must be used in both blog and forum
This is going to expose endpoints that will implement the business logic of our application.
The purpose is to implement the business logic in a way that it could be plugged into different underlying server technology.
API Server is the existing express server -> npm run express; However we are going to remove serving the static files from here. We going to have dedicated server for this.
Make yourself familiar with 1) LokiJS because we all will deal with persistence at one point in time 2) Writing tests with tape - see example test suite from lectures code examples - everyone of you must write one test suite for particular service (remember we will have services per each aspect that will weave into our app)
Please leave comment when you are already good to go with LokiJS and tape
HINT: custom / medium / discourse / ardb / draftjs
Random improvements on front end side...
Flexible deployments:
Logic on different server
App on different cloud
We are looking on the best architecture so we could:
create reusable npm modules
combine a lot of external APIs - Github / Slack / Medium / Discourse
fit the structure of internal to external models - e.g. Bragger Post - Medium Post (data transformation)
technology stack
more...
Here we are going to describe how we are going to present the application - the demo scenarios.
Initially our local DB is empty
We are going to try to enter with email into the system but there is no such user
Then we start the CLI and init the local DB with User Models (combined from slack/github)
Fill the email and login into the system where we see the user feed with posts etc.
Make a post
Like post when logged in with another user and see the result.
Create forum category / topic and post and write comment.
etc.
Try to import data from Medium/Discourse into our DB via connectors in seamless manner. This usually would be done via administrative interface but could be as well started from the CLI. Basically everything should be written in a manner that is reusable to be consumed via UI and CLI.
The imported data should be available in the User feed
We are going to demonstrate how we are able to switch the environments.
Execute the export script via CLI so we fill mongo db with data
Reuse http handlers that allow us to dynamically expose endpoints to Express
Configure the FE to work with another source of data - replace local with http server
Static resources will always be served from web pack dev server...they are easily transferable between CDNs
Execute the export script with another transformer appropriate to Arrow DB
Reuse http handlers that allow us to dynamically expose endpoints to Arrow
Configure the FE to work with another source of data - replace local with http server
Static resources will always be served from web pack dev server...they are easily transferable between CDNs
We need to have an open data which is really easy to export to another datastore.
That is why we use json files as our datastore.
This allows us to move fast with the application and in the same time we can easily put this data in appropriate store later on.
Write program that uses streams and do the following:
This program would be used by CLI described in #18
https://nodejs.org/api/stream.html
https://github.com/substack/stream-handbook
https://github.com/workshopper/stream-adventure - do this workshop
Here you can improvise with reading many files and writing into single file or reading source files and writing them into destination files with 1 to 1 mapping.
Design the program so it can be parametrized with receiving different transformer - mongoldb / arrowdb etc.
Get familiar with the complete JSON structure of braggers .... get familiar with ArrowDB SDK (one of next lectures will handle this) and write 1 transformer for ArrowDB so we could deploy the application on Arrow Cloud.
These could be useful:
https://github.com/dominictarr/JSONStream
https://github.com/pltod/hb-nodejs-2014/tree/master/week6 - some small apps that I made with streams before
Where data will be persisted and what will be the structure of each model used in the system
This is going to serve the static resources and the front end application. This is the web pack development server but could be any other that is able to serve static files.
Persistence module with http://lokijs.org/#/
Make yourself familiar with 1) LokiJS because we all will deal with persistence at one point in time 2) Writing tests with tape - see example test suite from lectures code examples - everyone of you must write one test suite for particular service (remember we will have services per each aspect that will weave into our app)
Please leave comment when you are already good to go with LokiJS and tape
https://github.com/substack/tape
The task is to create a service that will allow us to persist data into JSON files on the file system and write test suite with tape (as it is used in the lectures) to test it. Use LokiJS so you can learn about LokiJS and make the initial step to use it into our system.
You can try storing JSON data into files on the file system. Imagine we have to store users, blog posts etc. into different XXX.json files on the file system and we want to make it with LokiJS. Basically that will be our Database.
You can even think further with creating wrapper to LokiJS in the form of node Module like this:
//1. your implementation of the functions bellow based on LokiJS should be here
//2. then export your module API like that
module.exports = {
insertMany: insertMany,
insertOne: insertOne,
findAll: findAll,
rmAll: rmAll,
rmOne: rmOne
//OTHER METHODS AS NEEDED
}
You can see something similar done but with node-persist here https://github.com/pltod/hb-nodejs-2014/tree/master/shared/db/facade-node-persist
superagent or request or browser native module
responsibility for doing http requests to the API server
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.