erin-noe-payne / express-train Goto Github PK
View Code? Open in Web Editor NEWexpress-train, nodejs framework
express-train, nodejs framework
server.js must depend on middleware to guarantee the middleware stack is set up before the the app listen starts.
I am not sure if this is an issue with express-train, or something I am doing wrong.
When using the express-train boilerplate template, there seems to be an issue with the express.bodyParser() middleware.
In '/lib/middleware.js' is:
app.use(express['static'](app.set('public')));
app.use(connect_timeout({ time:app.config.request_timeout }));
app.use(express.cookieParser());
app.use(session_middleware);
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(app.router);
However in the logs of train, I never see the statement:
' middleware / bodyParser'
and the req.body is always undefined.
If in my route, I add express.bodyParser() before the controller function, the req.body is defined correctly:
app.post('/feature',express.bodyParser(), app.controllers.home.createFeature)
Please let me know if you need more info.
Thanks,
Dan
Will give us more power than trying to roll our own.
Had issues deploying to heroku because they don't support __dirname. It can be fixed easily by replacing instances with process.cwd()
not an issue, just a question
they both look pretty similar to me so what are the advantages of picking this over Base 12?
Supporting globs and multiple include patterns means I can use ! operator to support exclusion. Duh.
Train console does not require from app/index.js. So it will not take into account any overridden locations.
Right now the assumption is that index.js actually causes the server to listen - for easier use with run and cycle, but that prevents use with console. Solve it!
I was thinking about adding socket.io support and started with something like this:
app/lib/events.js:
var socketio = require('socket.io');
module.exports = function (app) {
app.io = socketio.listen(app.server);
app.io.configure(function () { app.io.set("log level", 3); ... });
// Event mapping
app.io.sockets.on("connection", function (socket) { ... } );
}
Does it look ok under the framework standards?
Locations can be overwritten at createapplication.
If a user gives a .json file rather than a directory for configs, loadConfigs will attempt to select [NODE_ENV] off of this object. Could cause unintended behavior if a .json file has an object with keys that collide with [NODE_ENV] or with "default"
The below is in outputted to my console after initial run of my newly scaffolded app. Any ideas on how to get rid of the below message?
DEBUG: Starting child process with 'node app/index.js'
========================================================================================
= Please ensure that you set the default write concern for the database by setting =
= one of the options =
= =
= w: (value of > -1 or the string 'majority'), where < 1 means =
= no write acknowlegement =
= journal: true/false, wait for flush to journal before acknowlegement =
= fsync: true/false, wait for flush to file system before acknowlegement =
= =
= For backward compatibility safe is still supported and =
= allows values of [true | false | {j:true} | {w:n, wtimeout:n} | {fsync:true}] =
= the default value is false which means the driver receives does not =
= return the information of the success/error of the insert/update/remove =
= =
= ex: new Db(new Server('localhost', 27017), {safe:false}) =
= =
= http://www.mongodb.org/display/DOCS/getLastError+Command =
= =
= The default of no acknowlegement will change in the very near future =
= =
= This message will disappear when the default safe is set on the driver Db =
========================================================================================
[express train application listening on 4000]
https://npmjs.org/package/repl.history
or custom implementation?
When trying to overwrite the config location, absolute paths do not work:
var tree = train(__dirname, {config: {path: '/absolute/path/to/dir'}});
Gets an error when starting the app:
Error: ENOENT, no such file or directory '/relative/path/to/app/absolute/path/to/dir'
When I try to run the tests, I get an error:
Error: Cannot find module '/express-train-fork/test/scaffold/app/models'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at traverseAndRegister (/express-train-fork/lib/app.js:107:22)
at /express-train-fork/lib/app.js:67:9
at Function.forEach (/express-train-fork/node_modules/lodash/dist/lodash.js:3039:15)
at ExpressTrain (/express-train-fork/lib/app.js:66:7)
at Context.<anonymous> (/express-train-fork/test/app.js:55:18)
at Test.Runnable.run (/express-train-fork/node_modules/mocha/lib/runnable.js:211:32)
at Runner.runTest (/express-train-fork/node_modules/mocha/lib/runner.js:358:10)
at /express-train-fork/node_modules/mocha/lib/runner.js:404:12
at next (/express-train-fork/node_modules/mocha/lib/runner.js:284:14)
at /express-train-fork/node_modules/mocha/lib/runner.js:293:7
at next (/express-train-fork/node_modules/mocha/lib/runner.js:237:23)
at Object._onImmediate (/express-train-fork/node_modules/mocha/lib/runner.js:261:5)
at processImmediate [as _immediateCallback] (timers.js:330:15)
Are the scaffold
helper files simply missing, or is there some magic going on I'm not aware of? ๐
Do I simply yo express-train
into a test/scaffold
directory?
Write clearer docs for how to write tests taking advantage of Nject
With commit bdd432b the traversal of files and directories for automatic dependency injection was changed which introduced a really nasty bug: express-train tries to require any kind of file in those directories, so now it chokes on .DS_store
files etc.
/project/bootstrap/.DS_Store:1
(function (exports, require, module, __filename, __dirname) {
^
Exiting process due to uncaught exception!
SyntaxError: Unexpected token ILLEGAL
at Module._compile (module.js:439:25)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at traverseAndRegister (/project/node_modules/express-train/lib/app.js:114:21)
at /project/node_modules/express-train/lib/app.js:110:13
at Array.forEach (native)
at traverseAndRegister (/project/node_modules/express-train/lib/app.js:108:15)
Some kind of file type filtering seems in order.
Anything I can do to help develop rails-like scaffolding? Is there already a skeleton or current attempt?
New try / catch block to detect a malformed express train module will swallow errors from that module. That is a bad thing.
Duh.
Have the express train command return an object which can register events, return resolved config, etc, and can be resolved at a later time.
app.start expects http or https on the config object, creates http and https servers (should probably be the job of nginx or something else in the architecture).
I am proposing to drop Express Train's lifecycle stages and move to an angular-style dependency injection system. At run time each file is registered by file name, and dependencies are resolved by variable. A dependency tree is built and each module is resolved in the order needed to run the app.
must remove!
I fixed it by changing my app.js into this:
var expressio = require('express.io');
var path = require('path');
module.exports = function(){
var app = expressio();
app.set('views', path.join(__dirname, "../views"));
app.set('public', path.join(__dirname, "../public"));
return app;
}
Error: static() root path required
at Function.module.exports (C:\Users\fraherm\workspace\test\node_modules\express\node_modules\connect\lib\middleware\static.js:49:20)
at module.exports (C:\Users\fraherm\workspace\test\app\lib\middleware.js:28:30)
at C:\Users\fraherm\workspace\test\node_modules\express-train\node_modules\nject\lib\nject.js:180:33
at Array.forEach (native)
at Function._.each._.forEach (C:\Users\fraherm\workspace\test\node_modules\express-train\node_modules\nject\node_modules\underscore\underscore.js:78:11)
at Tree.resolve (C:\Users\fraherm\workspace\test\node_modules\express-train\node_modules\nject\lib\nject.js:167:7)
at createApplication (C:\Users\fraherm\workspace\test\node_modules\express-train\lib\app.js:92:17)
at Object.<anonymous> (C:\Users\fraherm\workspace\test\app\index.js:3:18)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
This would be more of a feature request, can it be possible to implement a boilerplate template which has basic passpost-local & mongoose integration done, maybe follwoing this example https://github.com/jaredhanson/passport-local/tree/master/examples/express3-mongoose-rememberme .
This would save time and energy and makes it quickly to jump on matters that matter most, rather than handling repetitive patterns every time a new project starts.
As ExpressJS is updated to 4. Is there any plan to update expressjs version? If no, then why?
Hi
I generated the boilerplate and when trying to deploy to Nodejitsu, it fails due to the startup script. Kindly advise.
Thanks.
and underscores and stuff.
... express train and is you express application...
Should be
...express train and is youR express application...
Right now express-train has express 3 as a dependency and creates the server using it.
There is no way to specify which version of express you want to use.
Would it be possible to add that configuration in?
Thanks in advance,
Dan
Right now errors are inconsistent - they may be thrown or they may be returned via callback.
On line 12 of /app/lib/middleware.js, mongoose is not defined.
This is when you try to run a newly created train template.
Hi,
When using a default app and getting non existing URL the default error handler middleware express.errorHandler can't find req.headers.
"version": "0.0.22"
$ train new app
$ cd app
$ train run
...
[ express-train ] application listening on port 4000
GET /x
middleware / query 0ms
middleware / expressInit 1ms
middleware / static 2ms
middleware / responseTimeout 0ms
middleware / cookieParser 1ms
middleware / session 4ms
middleware / bodyParser 0ms
middleware / methodOverride 0ms
middleware / router
0ms
middleware / errorHandler undefined
TypeError: Cannot read property 'accept' of undefined
at errorHandler (/tmp/app/node_modules/express/node_modules/connect/lib/middleware/errorHandler.js:49:29)
at Object.handle (/tmp/app/node_modules/express-trace/lib/express-trace.js:106:9)
at next (/tmp/app/node_modules/express/node_modules/connect/lib/proto.js:190:15)
at /tmp/app/node_modules/express-trace/lib/express-trace.js:109:11
at pass (/tmp/app/node_modules/express/lib/router/index.js:107:24)
at Router._dispatch (/tmp/app/node_modules/express/lib/router/index.js:170:5)
at router (/tmp/app/node_modules/express/lib/router/index.js:33:10)
at Object.handle (/tmp/app/node_modules/express-trace/lib/express-trace.js:106:9)
at next (/tmp/app/node_modules/express/node_modules/connect/lib/proto.js:190:15)
at /tmp/app/node_modules/express-trace/lib/express-trace.js:109:11
responded to GET /x in 18ms with 500 "Internal Server Error"
Hi,
I'm not sure why, but when I try to run my app using [email protected]
and [email protected]
, I'm getting the following error when trying to run my app. I tried using the generator (generator-express-train) and kept getting similar errors with the setup that was generated too.
Error:
$ node app/index.js
[2016-02-29 19:31:58.846] [LOG] Configuring Express-Train from file: ../config
/home/mrodrig/lvm/node_modules/express-train/lib/app.js:136
throw new Error(file.path+': '+err)
^
Error: /home/mrodrig/lvm/node_modules/abbrev/CONTRIBUTING.md: SyntaxError: Unexpected identifier
at /home/mrodrig/lvm/node_modules/express-train/lib/app.js:136:13
at forOwn (/home/mrodrig/lvm/node_modules/lodash/dist/lodash.js:1907:15)
at Function.forEach (/home/mrodrig/lvm/node_modules/lodash/dist/lodash.js:3044:9)
at ExpressTrain (/home/mrodrig/lvm/node_modules/express-train/lib/app.js:131:5)
at Object.<anonymous> (/home/mrodrig/lvm/app/index.js:27:12)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Function.Module.runMain (module.js:447:10)
at startup (node.js:140:18)
at node.js:1001:3
Here's my express-train config in index.js:
var tree = train(__dirname,
{
config: {path: environment.etFileLocation}
});
Is there something wrong here? Why is it looking in the node_modules directory?
Thanks in advance!
When trying to create new train projects on windows with the latest npm build, train will fail with an unhandled error event.
I believe that Windows path concatenation should be handled differently than linux systems. On the other hand, the Train Angular Seed project can be started with no issues, the issue that I've found only impacts the new command.
Here is the cmd output:
C:\Users\gabriel\test>train new testme
Your boilerplate preferences file was written to C:\Users\gabriel.node-boilerplate.json
Your boilerplate preferences file was written to C:\Users\gabriel.node-boilerplate.json
events.js:72
throw er; // Unhandled 'error' event
^
Error: spawn ENOENT
at errnoException (child_process.js:980:11)
at Process.ChildProcess._handle.onexit (child_process.js:771:34)
I am migrating some older code to the latest version. I used a routes.js in my lib folder, but now there is a routes folder in the root when using yeoman. Please explain the migration?
Following the basic setup in the README, I get the error trying to do train run
:
Exiting process due to uncaught exception!
TypeError: Object [object Object] has no method 'start'
at Command.<anonymous> (/usr/local/share/npm/lib/node_modules/express- train/bin/commands/run.js:10:26)
at Command.<anonymous> (/usr/local/share/npm/lib/node_modules/express- train/node_modules/commander/index.js:249:8)
at Command.EventEmitter.emit (events.js:98:17)
at Command.parseArgs (/usr/local/share/npm/lib/node_modules/express-train/node_modules/commander/index.js:477:12)
at Command.parse (/usr/local/share/npm/lib/node_modules/express-train/node_modules/commander/index.js:370:21)
at Object.<anonymous> (/usr/local/share/npm/lib/node_modules/express-train/bin/train:18:9)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
Digging into the source it looks like in the project root index.js it calls require('./app/index.js').start();
and the ./app/index returns train(__dirname);
, and looking at the source there's no start()
method in the train object anymore. I can update the boilerplate, but what's the correct syntax now?
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.