https://github.com/felipekm/nodejs-hapijs-api-server
📮 API with JWT + MongoDB
https://github.com/felipekm/nodejs-hapijs-api-server
hapijs-backend hapijs-jwt mongodb nodejs-api nodejs-server
Last synced: 4 months ago
JSON representation
📮 API with JWT + MongoDB
- Host: GitHub
- URL: https://github.com/felipekm/nodejs-hapijs-api-server
- Owner: felipekm
- Created: 2021-09-02T15:14:51.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2025-01-13T15:26:10.000Z (over 1 year ago)
- Last Synced: 2025-09-07T05:39:05.322Z (9 months ago)
- Topics: hapijs-backend, hapijs-jwt, mongodb, nodejs-api, nodejs-server
- Language: JavaScript
- Homepage:
- Size: 220 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
NodeJS - HapiJS API Server
## Developing at NodeJS - HapiJS API Server - Monolith
> NodeJS - HapiJS API Server - Monolith built for study proposes, it provides **RESTFUL** services on resource oriented architecture projects (ROA).
> The barebone is located under `app/api` and `app/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 the `webapi` 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](https://github.com/felipekm/nodejs-hapijs-monolith).
## Configuring development environment
### Step 0: Getting into the project
Base project structure:
Files:
- `.env`: configuration file for environment variables
- `server.js`: the main file of the application
- `ecosystem.config.js`: the PM2 app configuration file
Folders:
- `app`: the application folder
- `app/api`: the api folder sectioned by version
- `app/core`: the core folder
- `app/core/plugins`: the plugins folder
- `app/core/workers`: the workers folder
#### Step 1: installing necessary tools
* install git: [git-scm](http://git-scm.com/)
* install NodeJS@12+: [nodejs.org](http://nodejs.org)
#### Step 2: preparing repository
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
```
### Step 3: run tests to check if things are fine, the tests file must be created in app/core/tests:
To run your tests:
```
npm test
```
## How to debug it
To debug we are explicity using the [Visual Code](https://code.visualstudio.com/):
* Open your the project in VS Code;
* Press `F5` or symply runs `node server.js` in this project folder;
### Development environment variables
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.
### NPM tasks
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.
### Support
If you find any problem or question please raise an issue