Coder Social home page Coder Social logo

trails's Introduction

Gitter NPM version Linux + OSX Build Status Windows Build Status Test Coverage Follow @trailsjs on Twitter

Trails is a modern, community-driven web application framework for Node.js. It builds on the pedigree of Rails and Grails to accelerate development by adhering to a straightforward, convention-based, API-driven design philosophy.

Getting Started

Install

$ npm install -g yo generator-trails
$ yo trails

Trailblaze

Trails uses Yeoman to generate scaffolding for new applications, and to create resources inside the application.

$ yo trails --help

Usage:
  yo trails

Generators:

  Create New Model
    yo trails:model <model-name>

  Create New Controller
    yo trails:controller <controller-name>

  Create New Policy
    yo trails:policy <policy-name>

  Create New Service
    yo trails:service <service-name>

Run

Once installation is complete, begin your journey!

$ node server.js

Happy Trails!

Trailpacks

Trailpacks extend the framework's capabilities and allow developers to leverage existing ecosystem tools through a simple and well-defined API. New features, behavior, APIs, and other functionality can be added to the Trails framework through Trailpacks.

Many Trails installations will include some of the following Trailpacks:

Compatibility

  • Windows, Mac, and Linux
  • Node 7.0 and newer

Documentation

See trailsjs.io/doc for complete documentation.

More Resources

Tutorials

Videos

Support

FAQ

See https://github.com/trailsjs/trails/wiki/FAQ

Contributing

We love contributions! Please check out our Contributor's Guide for more information on how our projects are organized and how to get started.

License

MIT

trails's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

trails's Issues

HATEOAS

One thing that was not implemented in Sails was the HATEOAS principle.

Basically, when doing a request, the response must contain informations on how to access to others states of the resource (removal, edition, etc...) or a linked one.

You can find more informations about this concept on Wikipedia and on the O'Reily book
RESTful Java with JAX-RS
.

I think you don't want to have overcomplicated API responses but this is a part of the REST architecture that I find missing in Sails.

i18n support

Trails should support i18n from the beginning, and as such should be included in the core. It will likely be the only dependency included in the core, possibly ever.

rename configfile trailpack.js -> app.js

The application needs an application-scoped configfile, and I think the trailpack config file needn't be so specific. Change the config namespace to app, and only trailpacks themselves should utilize the trailpack.js config file.

multi-tenancy database support

One of the reasons we did not move forward with sails was requirement for supporting multi-tenancy. Since that means different things to different developers, what I mean is using a different database connections for each client, which of course is based on the user logged into that session. Since I see lots of responses to this about sharding and solutions to just put them in the same database, I will also say that we have this architecture for valid reasons and differing solutions for differing reasons are not what I am looking for.

In .NET I have implemented a connection pooling scheme that pools based only on target server and credentials. As long as the credentials or server does not change, a transaction simply uses the correct database prior to executing. While this is no applicable to all database types, it works well enough for most traditional relational servers. Something similar here would rekindle our interest in another Rails-on-node project.

get something minimal at trailsjs.io

Hey, right now the trailsjs.io shows a domain parking page.
That's pretty fancy and ugly..
For sure a waiting page or something redirecting to the Github would be better.

Trails Brandmark, Logotype, and Theming

Hi everyone, just wanted to share with you our current branding efforts courtesy @jonhargreaves .

The second photo is a quick mock of the logo applied to the TrailsMix app, wanted to show a quick sense of it "in action" ๐ŸŒฒ

spreadsheet

trailsmixnewlogo

AssertionError: missing path in new trails application

info: Starting...
debug: trails event: trails:start
verbose: Trailpacks: All Validated.
debug: trails event: trailpack:all:validated
debug: trails event: trailpack:core:configured
debug: trails event: trailpack:repl:configured
debug: trails event: trailpack:router:configured
debug: trails event: trailpack:hapi:configured
debug: trails event: trailpack:all:configured
debug: trails event: trailpack:core:initialized
debug: trails event: trailpack:repl:initialized
debug: trails event: trailpack:router:initialized
error:
 AssertionError: missing path
    at Module.require (module.js:364:3)
    at require (module.js:385:17)
    at Object.registerViews (/Volumes/Repos/Coding/OpenSource/trails/test/node_modules/trailpack-hapi/lib/server.js:28:15)
    at Hapi.initialize (/Volumes/Repos/Coding/OpenSource/trails/test/node_modules/trailpack-hapi/index.js:37:16)
    at /Volumes/Repos/Coding/OpenSource/trails/test/node_modules/trails/index.js:65:26
    at process._tickDomainCallback (node.js:422:9)
    at Function.Module.runMain (module.js:459:11)
    at startup (node.js:138:18)
    at node.js:974:3
debug: trails event: trails:stop

New npm version needed

In order to generate a working default project with the generator, we need the i18n configuration and a default template engine.

i18n is already on master but PR is needed for template engine #23
Or if no template engine is configured update hapi to not throw this error (and push it to npm)

Inaccurate wording of FAQ answer

Some of the wording in the answer to 'Is Trails a fork of Sails?' is a little misleading, so would be a good idea to change it to avoid confusion about this project. Right now it says:

Trails is built and maintained by former members of the Sails.js core team

But that makes it sound like the core maintainers of Sails have become involved in this project. It would be more accurate to change it to something along the lines of:

Trails is built and maintained by a former Sails contributor and his team

(Would have submitted a PR myself, but I figured you might want to work with the wording a bit more before changing it.)

validate integrity of trailpack lifecycle before booting

Analyze the trailpack lifecycle configurations, and determine whether the trailpacks will load correctly, or if there is a mismatch in the lifecycle config (e.g. if a trailpack requires an event that no other configured trailpack intends to emit)

TypeError: Cannot read property 'compatibilityAPI' of undefined

Copied from #53

C:\Users\M7\trails-demo2>npm start

> [email protected] start C:\Users\M7\trails-demo2
> node server.js

info: Starting...
debug: trails event: trails:start
verbose: Trailpacks: All Validated.
debug: trails event: trailpack:all:validated
debug: trails event: trailpack:repl:configured
debug: trails event: trailpack:router:configured
debug: trails event: trailpack:core:configured
debug: trails event: trailpack:hapi:configured
debug: trails event: trailpack:all:configured
debug: trails event: trailpack:repl:initialized
debug: trails event: trailpack:router:initialized
error:
 TypeError: Cannot read property 'compatibilityAPI' of undefined
    at t.u.value (C:\Users\M7\trails-demo2\node_modules\i18next\bin\index.js:2:3238)
    at C:\Users\M7\trails-demo2\node_modules\trailpack-core\lib\i18n.js:6:15
    at Object.init (C:\Users\M7\trails-demo2\node_modules\trailpack-core\lib\i18n.js:5:12)
    at Core.initialize (C:\Users\M7\trails-demo2\node_modules\trailpack-core\index.js:34:21)
    at C:\Users\M7\trails-demo2\node_modules\trails\lib\trailpack.js:46:26
    at process._tickDomainCallback (node.js:425:9)
    at Function.Module.runMain (module.js:432:11)
    at startup (node.js:141:18)
    at node.js:980:3
debug: trails event: trails:stop

i18n for front

I never see this kind of feature in any framework but in every project I made with i18n the problem as occurred.
I would like to have one translation file per language but some translation are for front, some other for the back and some for both. I don't like to duplicate translation files to have one front and one back cause if you update one you have to update the other as well (and for all languages even if you don't know them)

I know i18n can be use in .jade and other template engine. But for applications with dynamic front component it happen that you have to translate keys under your javascript front files.

So I find it will be cool if translation file can allow to export i18n script to front with only translations allowed to it.

Maybe translation file can look like this :

{
    'front' : {
       'key' : 'translation'
    },
    'both' : {
      'key' : 'translation'
    },
    'back' : {
      'key' : 'translation'
    }
}

How guys did you do this kind of stuff anyway ? What do you think @tjwebb ? I see you're implementing i18n :)

JSON API Support

Are you planning to implement support for the JSON API spec? It would be a great feature to and there are already quite a few libraries for front end frameworks to support the spec. Some such as ember support it out of the box.

Use named routes

One of the things that we very often end up needing is to generate a url for some route in our app.

For example, let's say I have a route like this:
GET /resource/:resourceId/action/param1/:param1/param2/:param2

Later in our app, we need to generate an anchor tag with the link to that url. With the current implementation, routing logic will have to be duplicated into the function that creates the full urls.

One solution for this problem is using something like named-routes. ASP.NET MVC5 has its own way of reversible route definitions that might be useful to study.

coffeescript?

Any plan to support coffeescript at the application level?

Some info please?

Hi @tjwebb, I found this project in a comment of this article.

Can I ask about what's going on here? Is this project a new Framework like Sails but trying to follow a more modular (or pluggable) solution? Are you leaving Sails project for this one? What is the main goal of this new branch?

Slush.js instead of Yo?

Was'nt there a discussion about using Slush instead of Yo a while back? It was based on the usage of Grunt vs. Gulp. Since most people are migrating to Gulp, it would be nice if Trails used Slush instead.

Session authentication

I don't know if such functionality is outside of the scope of this project but sails-auth was a popular module in sailsjs. Could we improve on it in Trails and perhaps bake it into the core framework? Let's face it, the majority of apps will use it.

I propose we have a token based authentication strategy in Tails.

yo trails:whatevergenerator fails

i'm executing this command yo trails:model Customer and i get this error, same error for the others generators

module.js:328
    throw err;
    ^

Error: Cannot find module 'yeoman-generator/node_modules/path-exists'
    at Function.Module._resolveFilename (module.js:326:15)
    at Function.Module._load (module.js:277:25)
    at Module.require (module.js:354:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/home/f00lg/.nvm/versions/node/v5.3.0/lib/node_modules/generator-trails/generators/app/util.js:13:46)
    at Module._compile (module.js:398:26)
    at Object.Module._extensions..js (module.js:405:10)
    at Module.load (module.js:344:32)
    at Function.Module._load (module.js:301:12)
    at Module.require (module.js:354:17)
    at require (internal/module.js:12:17)

Package missing, where and how to fix ?

trying to start server

C:\Users\M7\trails-demo>npm start

> [email protected] start C:\Users\M7\trails-demo
> node server.js

module.js:328
    throw err;
    ^

Error: Cannot find module './controllers'
    at Function.Module._resolveFilename (module.js:326:15)
    at Function.Module._load (module.js:277:25)
    at Module.require (module.js:354:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (C:\Users\M7\trails-demo\api\index.js:1:85)
    at Module._compile (module.js:398:26)
    at Object.Module._extensions..js (module.js:405:10)
    at Module.load (module.js:344:32)
    at Function.Module._load (module.js:301:12)
    at Module.require (module.js:354:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (C:\Users\M7\trails-demo\index.js:3:15)
    at Module._compile (module.js:398:26)
    at Object.Module._extensions..js (module.js:405:10)
    at Module.load (module.js:344:32)
    at Function.Module._load (module.js:301:12)

npm ERR! Windows_NT 10.0.10586
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\M7\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "start"
npm ERR! node v5.3.0
npm ERR! npm  v3.5.3
npm ERR! code ELIFECYCLE
npm ERR! [email protected] start: `node server.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script 'node server.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the trails-demo package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node server.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs trails-demo
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls trails-demo
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Users\M7\trails-demo\npm-debug.log

Trying to make controller

C:\Users\M7\trails-demo>yo trails:controller Main
module.js:328
    throw err;
    ^

Error: Cannot find module 'yeoman-generator/node_modules/path-exists'
    at Function.Module._resolveFilename (module.js:326:15)
    at Function.Module._load (module.js:277:25)
    at Module.require (module.js:354:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (C:\Users\M7\AppData\Roaming\npm\node_modules\generator-trails\generators\app\util.js:13:46)
    at Module._compile (module.js:398:26)
    at Object.Module._extensions..js (module.js:405:10)
    at Module.load (module.js:344:32)
    at Function.Module._load (module.js:301:12)
    at Module.require (module.js:354:17)
    at require (internal/module.js:12:17)

Who's side is these error ? yo or trails:controller ???
Reinstalling bouth of them didn't helped!..

Class for models, controllers, policies and services

It would be nice to have some classes :
TrailsModel, TrailsController, TrailsPolicy and TrailsService instead of {} directly. It can be useful to extends some trailpack functionalities from trails project.
It can be more 'cleaner' / easy to understand/learn to have classes for this kind of objects.

trailpack icons

Need icons for the following things:

  • trailpack
  • hapi trailpack
  • router trailpack
  • repl trailpack
  • core trailpack

I wonder if we can continue the node.js hexagon theme and show a trail running through them when they're connected up? If this idea is terrible let me know.

trails:stop event should be more forcing

We don't really want any further events firing after trails:stop is emitted.

debug: trails event: trails:start
verbose: Trailpacks: All Validated.
debug: trails event: trailpack:all:validated
debug: trails event: trailpack:core:configured
debug: trails event: trailpack:smokesignals:configured
debug: trails event: trailpack:repl:configured
debug: trails event: trailpack:router:configured
debug: trails event: trailpack:waterline:configured
debug: trails event: trailpack:all:configured
debug: trails event: trailpack:smokesignals:initialized
debug: trails event: trailpack:repl:initialized
debug: trails event: trailpack:router:initialized
error:
 TypeError: lib.i18n.loadLocales is not a function
    at Core.initialize (/Users/tjwebb/workspace/trails/trailpack-core/index.js:55:14)
    at /Users/tjwebb/workspace/trails/trails/lib/trailpack.js:46:26
    at process._tickDomainCallback (node.js:411:9)
    at Function.Module.runMain (module.js:469:11)
    at startup (node.js:136:18)
    at node.js:963:3
debug: trails event: trails:stop
debug: trails event: trailpack:waterline:initialized

Footprint override

Give us the possibility to override the default FootprintController methods per controller.
It can be related to #42 cause if we have class for controllers we can but defaults Footprint methods under that class and under each controller we can override or not footprint behavior :)

HMVC

I was wondering if you guys would be open to supporting an HMVC setup with trails? It's something that I've found has improved my development massively, and currently I'm doing it with my front-end code, but as I'm using sails, I can't use it with my backend code. It would be great if we could get this.

For those unaware, currently the backend is defined like this:

  • api
    • controllers
      • CommentController
      • UserController
    • models
      • Comment
      • User
    • policies
      • loggedIn
    • services
      • CommentService
      • UserService

HMVC is where you could organise it more like this:

  • api
    • User
      • UserController
      • UserModel
      • UserService
      • LoggedInPolicy
    • Comment
      • CommentController
      • CommentModel
      • CommentService

And it means that everything you need for a particular feature is in the folder together.

Ideally, we would also be able to add the routes as individual files into these folders as well, that would be brilliant. I really hope you look to doing this, as it would mean that there was a massive reason for me to use Trails (as I've not found a good node framework that uses hmvc yet).

Fresh install of trails fail

After doing yo trails and running command npm start I get following error

debug: trails event: trailpack:core:constructed
debug: trails event: trailpack:repl:constructed
debug: trails event: trailpack:router:constructed
debug: trails event: trailpack:hapi:constructed
debug: trails event: trails:start
info: Starting...
debug: trails event: trailpack:repl:validated
debug: trails event: trailpack:hapi:validated
debug: trails event: trailpack:core:validated
debug: trails event: trailpack:router:validated
debug: trails event: trailpack:all:validated
debug: trails event: trailpack:repl:configured
debug: trails event: trailpack:router:configured
debug: trails event: trailpack:core:configured
debug: trails event: trailpack:hapi:configured
debug: trails event: trailpack:all:configured
debug: trails event: trailpack:repl:initialized
debug: trails event: trailpack:router:initialized
error: 
 AssertionError: missing path
    at Module.require (module.js:352:3)
    at require (internal/module.js:12:17)
    at Object.registerViews (/Users/hussainanjar/workspace/personal/trailsjs/node_modules/trailpack-hapi/lib/server.js:28:15)
    at Hapi.initialize (/Users/hussainanjar/workspace/personal/trailsjs/node_modules/trailpack-hapi/index.js:37:16)
    at /Users/hussainanjar/workspace/personal/trailsjs/node_modules/trails/lib/trailpack.js:43:26
    at process._tickDomainCallback (node.js:425:9)
    at Function.Module.runMain (module.js:432:11)
    at startup (node.js:141:18)
    at node.js:980:3
debug: trails event: trails:stop
error: 
 TypeError: Cannot read property 'compatibilityAPI' of undefined
    at t.u.value (/Users/hussainanjar/workspace/personal/trailsjs/node_modules/i18next/bin/index.js:2:3238)
    at /Users/hussainanjar/workspace/personal/trailsjs/node_modules/trailpack-core/lib/i18n.js:6:15
    at Object.init (/Users/hussainanjar/workspace/personal/trailsjs/node_modules/trailpack-core/lib/i18n.js:5:12)
    at Core.initialize (/Users/hussainanjar/workspace/personal/trailsjs/node_modules/trailpack-core/index.js:34:21)
    at /Users/hussainanjar/workspace/personal/trailsjs/node_modules/trails/lib/trailpack.js:43:26
    at process._tickDomainCallback (node.js:425:9)
    at Function.Module.runMain (module.js:432:11)
    at startup (node.js:141:18)
    at node.js:980:3
debug: trails event: trails:stop

this.app.log() is not a function

An error throw when I try to use this.app.log('something') but this.app.log.info('something') works.

TypeError : this.app.log is not a function

Support formatted footprints

It would be nice if footprint can support different format like JSON:API.
Also JSON:API allow to add metas datas, here is how I think it can be integrated to trails footprint :

module.export = class MyFootprint extends Footprint
{
    beforeSending(data, method, next){
         ...//Add some meta datas 
         next(null, data)
    }

}

It can be related to : #35

Database migrations

Hi there,

In SailsJS, it was clear that it was up to the developer to write and maintain their own database migrations.

I find it a massive productivity boost to have the ability to generate migrations based on model changes or at the very least have a built-in migration runner. Does Trails have any plans for supporting database migrations or is this considered a separate concern?

Thanks.

Config/web.js should be move under trailpack

I think the config/web.js shouldn't be under trails/archetype and be under trailpack-hapi/archetype, trailpack-express4/archetype... If some web server have default values other than port to put in it they can't actually.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.