soygul / koan Goto Github PK
View Code? Open in Web Editor NEWKOAN (Koa, Angular, Node, Mongo) starter kit for full-stack JavaScript web development.
License: MIT License
KOAN (Koa, Angular, Node, Mongo) starter kit for full-stack JavaScript web development.
License: MIT License
The is new Koa recommendation to store request state info is ctx.state
namespace. We have lots of this.user
as state info and can make them into this.state.user
but that kind of adds verbosity so this is to be evaluated further.
Hi soygul,
This problem show up recently.
WebSocket connection to 'ws://localhost:3000/?access_token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJlbWFpbCI6ImNodWNrQGtvYW4uaGVyb2t1YXBwLmNvbSIsIm5hbWUiOiJDaHVjayBOb3JyaXMiLCJpZCI6MiwicGljdHVyZSI6Ii9hcGkvdXNlcnMvMi9waWN0dXJlIiwiaWF0IjoxNDI3ODIzNDEwLCJleHAiOjE0MzU1OTk0MTB9.2EjG683rHAAK6oexDJw_vzD6m3aDeT5BTrsKgy0Sdo4' failed: HTTP Authentication failed; no valid credentials available
After digging, I found it is caused by koa-jwt update.
[email protected] is workable.
I think you might need to specify the version or fix the hack in ws.js
(https://github.com/soygul/koan/blob/master/server/config/ws.js#L29)
Add tests w/:
Also divide grunt test task into test:client-unit, test:client-e2e, test:server tasks.
Note: Client side tests should run in a real browser (Chrome by default) in a development environment rather than PhantomJS (which is the default for test environment like Travis). This sort of usage schema is nicely laid out in angular-seed tests.
Can be one column user profile photo and other column as user info.
Wiring comments over websocket needs a bit more work to prevent dupes and work properly..
E.g. visit http://localhost:3000/asdf/
(Where "/asdf/" is not a valid route.)
This would be a nice feature to be able to chat with anyone online. It would also be a good sample for bidirectional communications over WebSockets using JSON-RPC 2.0.
Once the core is more stable, we really need dependency numbers in package.json
and bower.json
in place of "latest" tags.
It's also good to use ranged versions only locking the major version like "koa-logger": "~1"
We now have this implemented over several files. We can make a proper npm package (or use an existing one if such thing exists) for this exact purpose.
WebSocket reconnect with exponential back-off is important. We can use code from one of:
which is basically:
function createWebSocket () {
var connection = new WebSocket();
connection.onclose = function () {
setTimeout(function () {
// Connection has closed so try to reconnect every 10 seconds.
createWebSocket();
}, 10*1000);
}
};
This is related to #16.
Currently we're using angular-seed
repo 1:1 in our client app. However this is very basic and does not incorporate a modular structure. There are great examples of that out there like:
We might however just wait for angular-seed to migrate to a more modular architecture (probably with angular 2.0). So there is a decision to be made here.
As in: https://github.com/meanjs/mean/blob/master/Dockerfile
Fig might also be useful instead of separate curl commands to get deps.. or there maybe a proper node 0.11 + mongo image already.
node-mongo v3.0 is the target, as v2.0 driver is not 100% tested to be compatible with mongodb 3.0 line.
I guess that https://github.com/jeffbcross/ngSocket will be a best approach for using WS in AngularJS services.
We might actually need something like koa-validator
similar to express-validator
to facilitate things a bit.
..or it might be a better idea not to bother users with that? just leave a notification for user which he/she can deal with later.
grunt test
doesn't pass.
Mocha test of server side code fails with:
"SyntaxError: Unexpected token *"
It makes serving angular from a sub-directory a nightmare.
Also need to test this from a sub-directory and make sure that everything works as expected.
Current user object refs stored in the database and JWT token are like {id:1, name: ..., picture: '/api/users/:id/picture'}
Picture path is really something that needs to be resolved during runtime. It also should not be embedded in the JWT token as it makes the token very long. It is a shame that this even slipped through!
HTTP authorization header forces browser to do and additional preflight request (OPTIONS) before the actual request so it is better to simply stick to access_token=JWT
query param.
This will also require a pull request to koa-jwt
module as query token feature is not implemented yet.
We now have LF and CR-LF mixed
Configuration options are leaking all over the code. Even the project name (KOAN) is used in many different places in plain text. Consolidate all config options in config.js
On production environments, we need grunt tasks to execute on 'npm postinstall' and do following:
Dist
folder.ng-annotate
the js files, ng-html2js
the templates, and merge everything into a single js/css file (though this hinders bug hunt in release builds as it will obscure exception stack traces so this is debatable)Currently implementation is just a stub so expand it into real working stuff along with proper configuration options.
Basic things like app name, home title (KOAN Home) is all plain text. Put these configurable stuff in a simple configuration file in a central location (maybe not?)
Also rename comments/docs like "KOAN configuration ..." to "App configuration ..." so that rebranding will be easier.
any thoughts on adopting http://angular-ui.github.io/bootstrap/?
Remove the separate login.html page (and jquery
dependency - still needed for bootstrap though).
Instead make the first landing page the credentials page, which redirects to home if token is in localstorage already. I don't know if this would look nice or flicker so needs experimentation.
This could be implemented as a real-time search if MongoDB 2.6 full-text search feature becomes available. Otherwise regex search would be too slow for real-time searching.
Controllers get instantiated each time the user browses to the same route so not unregistering from events inside controllers will prevent controller destruction. Users can always manually unregister from events using $scope.$on('$destroy', fn)
but we can automate this process during event registration with a stub like following:
event.subscribe($scope, fn) {
callbacks.add(fn);
$scope.$on('$destroy', event.unsubscribe(fn));
}
This should improve performance on selected placed by a large margin. Docs: https://docs.angularjs.org/guide/expression#one-time-binding
Mixing infrastructure related code with sample app implementation code makes merging changes from KOAN repo into user's own app repo very hard. For instance in client/js/services.js
file contains the REST API client and WebSocket client implementations as well as sample app related endpoint code. This is quite confusing when resolving merge conflicts while pulling KOAN repo. Following files are specially problematic:
client/*.html
client/partials/*.html
client/js/*.js
server/config/mongo-seed.js
server/config/mongo.js
server/controllers/*.js
server/controllers/*.js
test/**/*.js
We can even separate the sample app implementation into a sub directory like /example
.
Also implementing things like chat box (IM window) as re-usable addons may remove lots of clutter and possible merge conflict headaches.
This will also enable us to use koa-validator which requires a body parser for checkBody()
function to work.
We can use native Angular Material Design implementation for this: https://github.com/angular/material
This invalidates #35 (as it replaces Bootstrap/UI-Bootstrap) and enforces #15 (as native Angular Material implementation also uses SASS, though I still like stylus due to being node.js only).
Background: karma-runner/karma#1141
It would be nice to add business logic to an object representing the entity in Mongo.
Code is getting rather cluttered and duplicated in places. Review, refactor, and simplify the code (especially ws and controllers).
Also we should use a lot more of jsdoc to properly document a lot of the design choices and the code in general.
Hello,
First I have to thank you for this project. You have save me countless hours attempting to organize all of this on my own.
Question: When you create a new user you are not using the default mongoID. Why are you using a sequence instead?
// get the latest userId+1 as the new user id
// this is exceptional to user creation as we want user ids to be sequential numbers and not standard mongo guids
Also get the configuration from a common config file for /api
root etc.
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.