Generating an app
Now let's write a new project using the Feathers generators.
This project will have users who may be members of one or more teams. We want to display teams with all their members.
Create the app
The first thing we do is generate the basic app. For that, we will first have to create and move into a new folder:
mkdir feathers-app cd feathers-app
Then we can run:
feathers generate app
The generator creates some modules reflecting your choices. The modules are properly wired together and structured as recommended by the Feathers team.
They are mostly boilerplate and organized as follows:
Contains the resources to be served. A sample favicon and HTML file are included.
Contains the Feathers server.
hooks/ contains your custom hooks, usually those general enough to be used with multiple services. A simple but useful logger is provided as an example.
middleware/ contains your Express middleware.
services/ will contain the services.
index.js is used by node to start the app.
app.js configures Feathers and Express.
Contains the tests for the app. app.test.js tests that the index page appears, as well as 404 errors for HTML pages and JSON.
is compatible with the EditorConfig project and helps developers define and maintain consistent coding styles among different editors and IDEs.
contains defaults for liniting your code with ESLint.
specifies files which are not to be published for distribution.
contains the license so that people know how they are permitted to use it, and any restrictions you're placing on it.
It defaults to the Feathers license.
The generated code will look familiar. It contains nothing more than what we have covered previously. The main advantages of the Feathers generators are
Generators structure your app. The generated modules are structured as recommended by the Feathers team.
Generators write the repetitive boilerplate so you don't have to.
Generators handle database specifics. The generators will generate code for different databases so you don't have to investigate how to do so.
Next we will add authentication to the application we just generated.