NodeJS - HapiJS API Worker - Monolith built for study proposes, it provides RESTFUL services on resource oriented architecture projects (ROA).
The barebone is located under
app/api
andapp/core
, it is desgined by default covered by an Users API which is the authentecion is supported by a JWT plugin (app/core/plugins). There is also a Workers layer which comes with thewebapi
as default but it also ables you to create your own workers such Notification (notify) or Transactions (shake data in db) workers. If you need more details of how apply in your business feel free to get in touch and I'll be happy to help.
The project is open source and it is hosted on Github.
Base project structure:
Files:
.env
: configuration file for environment variablesserver.js
: the main file of the applicationecosystem.config.js
: the PM2 app configuration file
Folders:
app
: the application folderapp/api
: the api folder sectioned by versionapp/core
: the core folderapp/core/plugins
: the plugins folderapp/core/workers
: the workers folder
- install git: git-scm
- install NodeJS@12+: nodejs.org
Clone repository or fork it to your github account:
git clone https:/github.com/felipekm/nodejs-hapijs-monolith
Install project packages:
cd nodejs-hapijs-monolith
npm install
To run your tests:
npm test
To debug we are explicity using the Visual Code:
- Open your the project in VS Code;
- Press
F5
or symply runsnode server.js
in this project folder;
For development, you must set this variables and values in your OS:
- NODE_ENV: development
- ENGINE: The engine to start the process, the defined value matches the folder name at
app/core/workers/NAME
, the defaut is `webapi, you can have several others such a Notificator or Transactions worker that keeps running every time.
Several tasks are scripted to make things easier to dev team. In this project, you will find:
npm start
: this task is only used on AWS EC2 machine.npm test
: runs all automated tests and coding best practices check.npm stop
: kill the process.npm dev
: debug (dev) mode using nodemon.
If you find any problem or question please raise an issue