Quick start project to create a Hapiness application with all its features.
Download this starter and change hapinessjs/quick-start
and @hapiness/quick-start
, according your module name and repository, in these files:
package.json
README.md
In README.md
, you need to update the documentation to explain what's your module and what it does.
Delete .travis.yml
if you don't want to have travis-ci integration.
All files for your application will be in src
folder and wrote in Typescript
.
All tests files for your module will be in test
folder and wrote in Typescript
too.
- Unit tests will be in
test/unit
folder - Integration tests will be in
test/integration
folder
All packaging files for your module will be in tools
folder and wrote in Typescript
too.
tsconfig.json
is used for development process and tsconfig.build.json
is used for build process.
In both case, add externals types from @types/{...}
inside compilerOptions.types
array.
tslint.json
contains all rules for Typescript
validation during pretest
process.
yarn.lock
contains fixed packages' versions for all node_modules
used in your module.
See yarn cli documentation to know how to use it.
package.json
contains your module definition with name, description, scripts, dependencies, etc.
To install existing or new dependencies use npm
or yarn
. We advice to use yarn
to have the same version that us.
In scripts
part, you have all needed scripts to work. All scripts reference elements in Makefile
.
If you want to use nvm
, install node
version according .nvmrc
file and type:
$ cd path/to/hapiness/application
$ nvm use
All your application's contents must be inside src
folder.
Each folder must have a barrels
index file.
We have a convention name for each files so follow this guideline to be ok with the next hapiness-cli
To have live reload during development, just execute:
$ cd path/to/hapiness/application
$ yarn run dev:watch
or
$ npm run dev:watch
You can organize your application by modules or write services, routes and/or libraries in the root folder of your application.
If you want to organize your application by modules, you need to follow the guideline of @hapiness/empty-module project.
All services files must be inside src/services
folder and named {my-service}.service.ts
. Class will be {MyService}Service
.
Service needs to have @Inject()
decorator and be added inside module metadata
's providers array.
Export it with barrels
index at the root of src/services
.
You can organize services by features and create folders for that. Don't forget to create barrels
index for each folder.
All routes files must be inside src/routes
folder and organize by resources. In each resource folder, you need to create barrels
index and method file named {method}.route.ts
. Class will be {MethodResource}Route
.
Route needs to have @Route({...})
decorator and be added inside module metadata
's declarations array.
Export it with barrels
index at the root of src/routes
.
All libraries files must be inside src/libraries
folder and named {my-library}.library.ts
. Class will be {MyLibrary}Library
.
Library needs to have @Lib()
decorator and be added inside module metadata
's declarations array.
Export it with barrels
index at the root of src/libraries
.
You can organize libraries by features and create folders for that. Don't forget to create barrels
index for each folder.
You must unit test each service, route and library.
Your application and services must be tested with an integration in Hapiness
server application.
Each file name will be suffixed by test
: {my-module}.module.test.ts
, {my-service}.service.test.ts
, {resource}.{method}.route.test.ts
or {my-library}.library.test.ts
.
Classes will be suffixed by Test
: {MyModule}ModuleTest
, {MyService}ServiceTest
, {MethodResource}RouteTest
or {MyLibrary}LibraryTest
.
To run your tests, just execute:
$ cd path/to/hapiness/application
$ yarn run test
or
$ npm run test
Coverage result will be inside ./coverage/lcov-report
folder. Just open the folder in your browser to see the result.
Build your project:
$ cd path/to/hapiness/application
$ yarn run build
or
$ npm run build
Packaging will be created inside dist
folder. You must to publish only the content of this folder.
- v1.0.0-beta.2 (2017-05-02)
- Create
quick-start
application. - Create tests for each component.
- Application guideline style.
- Documentation.
- Module version related to core version.
- Create
Julien Fauville | Antoine Gomez | SĂ©bastien Ritz | Nicolas Jessel |
Copyright (c) 2017 Hapiness Licensed under the MIT license.