apsavin / bnsf Goto Github PK
View Code? Open in Web Editor NEWbem node single page application framework
License: MIT License
bem node single page application framework
License: MIT License
I have page with error inside bemtree. It's very convenient to debug it when it renders on client. Debug it during generation on server is pretty hard so I suggest the following:
When something goes wrong I get stake trace like this:
14:22:02.568 - error: Error process page /test-menu GET Error: Parameter "filePath" has bad value "undefined", not suitable for path generation
at RouterBase._getParameterValue (/home/jifeon/projects/bnsf-adwiki/libs/bnsf/node_modules/router-base/lib/router-base.js:435:19)
at /home/jifeon/projects/bnsf-adwiki/libs/bnsf/node_modules/router-base/lib/router-base.js:374:30
at String.replace (native)
at RouterBase._generate (/home/jifeon/projects/bnsf-adwiki/libs/bnsf/node_modules/router-base/lib/router-base.js:370:30)
at RouterBase.generate (/home/jifeon/projects/bnsf-adwiki/libs/bnsf/node_modules/router-base/lib/router-base.js:348:29)
at BEMContext.<anonymous> (/home/jifeon/projects/bnsf-adwiki/desktop.bundles/index/index.bemtree.js:807:35)
at run (/home/jifeon/projects/bnsf-adwiki/desktop.bundles/index/index.bemtree.js:179:15)
at BEMContext.<anonymous> (/home/jifeon/projects/bnsf-adwiki/desktop.bundles/index/index.bemtree.js:120:14)
at bodyHandler (/home/jifeon/projects/bnsf-adwiki/desktop.bundles/index/index.bemtree.js:98:54)
at apply (/home/jifeon/projects/bnsf-adwiki/desktop.bundles/index/index.bemtree.js:119:40)
Error message is pretty useful and complete, but stack trace is uninformative. I'm talking about:
/index.bemtree.js:807:35
It's really annoying moment during usual development
How can I specify defaults for API routing. Here is it:
- id: auth
path: /auth
host: localhost:1337
- id: repos
path: /user/repos
host: localhost:1337
I do not want to copy the host
field.
bump
It seems that we need a method for RequestListener browser implementation
It's very often situation, when links have no relation to data transformation, they are just for decoration, their place is inside BEMHTML, but we can't use them there because path
is not reachable inside BEMHTML. Why?
Suppose I have a page with list of links, each link refers to concrete data which should be loaded by AJAX. I want to use bundled mechanism for blocks loading aka request-listener but do not want replace the whole page but specific block. How can I do it? You can give me a short answer and I will write an article to the wiki.
Suppose I do request to the api and get 403 status. So I want to redirect user to login page. How can I do it?
SyntaxError: Unexpected token �
at Object.parse (native)
at ApiRequester.decl._processBody (/home/jifeon/projects/bnsf-adwiki/libs/bnsf/blocks/api-requester/api-requester.node.js:102:29)
at Request._callback (/home/jifeon/projects/bnsf-adwiki/libs/bnsf/blocks/api-requester/api-requester.node.js:55:33)
at Request.self.callback (/home/jifeon/projects/bnsf-adwiki/libs/bnsf/node_modules/request/request.js:121:22)
at Request.emit (events.js:98:17)
at Request.<anonymous> (/home/jifeon/projects/bnsf-adwiki/libs/bnsf/node_modules/request/request.js:985:14)
at Request.emit (events.js:117:20)
at IncomingMessage.<anonymous> (/home/jifeon/projects/bnsf-adwiki/libs/bnsf/node_modules/request/request.js:936:12)
at IncomingMessage.emit (events.js:117:20)
at _stream_readable.js:929:16
This error occurs if response from the api is not in JSON format
get(route, routeParameters, callback)
apiRequester.get(route, routeParameters)
apiRequester.post(route, routeParameters, body)
When user does apiRequester.post(route, body, callback)
he gets wrong behavior: callback treated as FormData.
Maybe, we can just check that arguments are correct and throw an error otherwise.
in the form like /api?r[]=my-route&rP[]=null
so it would be possible to use popular ajax form plugins.
That is :) preventDefault prevents only origin event, but bnsf loads the page in any case. I think we should look at defaultPrevented property.
How can I configure bnsf to use current domain as domain for static server
API is not run. I tried to open the page and see 502 in console:
Start process page page-500
Error process page / GET { error: '<html>\r\n<head><title>502 Bad Gateway</title></head>\r\n<body bgcolor="white">\r\n<center><h1>502 Bad Gateway</h1></center>\r\n<hr><center>nginx/1.8.0</center>\r\n</body>\r\n</html>\r\n',
body: '<html>\r\n<head><title>502 Bad Gateway</title></head>\r\n<body bgcolor="white">\r\n<center><h1>502 Bad Gateway</h1></center>\r\n<hr><center>nginx/1.8.0</center>\r\n</body>\r\n</html>\r\n',
response: { statusCode: 502, statusText: undefined },
handled: true }
API request GET http://api.adwiki.dev/auth/github/callback has status 502
<html>
<head><title>502 Bad Gateway</title></head>
<body bgcolor="white">
<center><h1>502 Bad Gateway</h1></center>
<hr><center>nginx/1.8.0</center>
</body>
</html>
but browser wait for something... and wait and wait...
I have following code:
block('user').content()(function () {
return this.get('login', this.ctx.loginParams).then(function (data) {
if (data.body.authenticated) {
return [
data.body.user.name,
{
block: 'link',
content: 'logout',
url: path('page-logout')
}
];
}
return {
block: 'link',
content: 'Authenticate through GitHub',
url: path('github-auth')
};
});
});
Route for page-logout
is not set, it causes the block is not rendered at all without any errors in console.
I wanna see warning or error in the console
Now bnsf looks at BEMHTML_ENV=development, BEMTREE_ENV = development env variables to recognize development environment, but there is NODE_ENV variable which used by many other libraries. Maybe we should look at this if BEMHTML_ENV and BEMTREE_ENV are not set?
How to reproduce:
1 click on a link
2 click on another link quickly, while page is loading
Actual result:
error 500
Expected result:
page from the last link url
Cookies for API server are stored inside bnsf, but I want to connect to API server directly by websockets and of course I lose my authorization because I don't have necessary cookies on the client. I remember that I have possibility to write my own controllers in bnsf (I think I can get my cookies this way) but there is no any docs about it.
I think:
Including request (see #47)
Suppose I have a number of pages which can be accessed only by authorized users. Of course I can check authentication inside each page and redirect user to login page if he is unauthorized. But I do not want to copy any piece of code. By the way how can I do redirect?
I think the special place must exist where I can define the rules for the privacy policy (maybe it is routing?)
I think it would be very convenient to see what queries happen
Current result: static server falls down and stops watching the files, if you break gulp work and run it again it won't help you, because static server process is detached. You need to stop the node process manually
Expected:
Initially there are only four files in the desktop.bundles directory, but after bem make
files that generated automatically are placed to the same directory. It is very inconvenient. I want it be in separated places.
Now bnsf automatically routes user to URL specified in the href attribute of the links using AJAX, so we get SPA very easy. I think it could behave itself for forms in similar way
Creating new pages a so boooooring. Can I do something like this:
bem create page-my-super-page
?
To avoid routing duplication it would be great if bnsf would be able to request api routing from api server.
How to reproduce:
Suppose I have a page and a block inside it. Here is bemhtml for the block:
block('entity')(
elem('label')(
tag()('span')
),
elem('short-description')(
tag()('span'),
match(this.ctx.shortInfo)(
content()(function () {
return ' - ' + this.ctx.shortInfo;
})
)
)
);
It fails with error
Error process page /backbonex/backbone.view.elements GET TypeError: Cannot read property 'shortInfo' of undefined
at BEMContext.templates (/home/jifeon/projects/adwiki__front/bundles/index/index.bemhtml.js:1103:23)
at run (/home/jifeon/projects/adwiki__front/bundles/index/index.bemhtml.js:165:13)
at BEMContext.<anonymous> (/home/jifeon/projects/adwiki__front/bundles/index/index.bemhtml.js:114:14)
at bodyHandler (/home/jifeon/projects/adwiki__front/bundles/index/index.bemhtml.js:92:54)
at apply (/home/jifeon/projects/adwiki__front/bundles/index/index.bemhtml.js:113:40)
at bemApply (/home/jifeon/projects/adwiki__front/bundles/index/index.bemhtml.js:363:20)
at BEMContext.ctx (/home/jifeon/projects/adwiki__front/bundles/index/index.bemhtml.js:704:13)
at run (/home/jifeon/projects/adwiki__front/bundles/index/index.bemhtml.js:173:15)
at BEMContext.<anonymous> (/home/jifeon/projects/adwiki__front/bundles/index/index.bemhtml.js:114:14)
at bodyHandler (/home/jifeon/projects/adwiki__front/bundles/index/index.bemhtml.js:92:54)
Of course there is a workaround: just match this.ctx && this.ctx.shortInfo
, but there is nothing about it in the bem docs, and I think it's because ctx
must be defined every time.
Error appears during page block generation.
Need to log messages on several levels, such as error
, warning
, info
, debug
etc. It's very important to log requests and responses on most verbose level.
Also want to mention specific situation: if API returns not JSON with application/json header then all you see in console is just a mention about URL and the fact JSON has not parsed. I think in this situation not only original error should be logged but also whore response.body
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.