-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from gotocva/v1.1.0
💎 new stable version release
- Loading branch information
Showing
16 changed files
with
479 additions
and
379 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,156 +44,65 @@ node nila create:model <modelName> | |
### Directory structure | ||
|
||
```bash | ||
[-] src | ||
|-- config | ||
| |-- app.config.js | ||
| |-- db.config.js | ||
|-- controllers | ||
| |-- user.controller.js | ||
|-- database | ||
| |-- mongoose.db.js | ||
|-- logger | ||
| |-- index.js | ||
| |-- pm2-viewer.js | ||
|-- middlewares | ||
| |-- auth.middleware.js | ||
| |-- objectid.middleware.js | ||
|-- models | ||
| |-- user.model.js | ||
|-- routes | ||
| |-- index.js | ||
| |-- user.routes.js | ||
|-- utils | ||
| |-- email.util.js | ||
| |-- encryption.js | ||
| |-- response.js | ||
| |-- xss.js | ||
|-- validators | ||
| |-- user.validator.js | ||
|-- express.js | ||
|-- [-] app | ||
| |-- index.js | ||
|-- [-] config | ||
| |-- mongoose.js | ||
|-- [-] cron | ||
| |-- index.js | ||
|-- [-] modules | ||
| |-- admin | ||
| |-- admin.controller.js | ||
| |-- admin.model.js | ||
| |-- admin.routes.js | ||
|-- [-] public | ||
|-- [-] swagger | ||
| |-- docs | ||
| |-- index.js | ||
|-- [-] test | ||
| |-- admin.test.js | ||
| |-- app.test.js | ||
|-- [-] utils | ||
| |-- crypto.js | ||
| |-- logs.js | ||
| |-- params-validator.js | ||
| |-- response.handler.js | ||
|-- [-] views | ||
| |-- index.pug | ||
| |-- layout.pug | ||
|-- index.js | ||
[-] tests | ||
- .babelrc | ||
- .env-sample | ||
- .eslintrc | ||
- .gitignore | ||
- ecosystem.config.json | ||
- jest.config.js | ||
- jsconfig.json | ||
- nila | ||
- package-lock.json | ||
- package.json | ||
- README.md | ||
|- .env.example | ||
|- .eslintrc | ||
|- ecosystem.config.json | ||
|- jest.config.js | ||
|- package-lock.json | ||
|- package.json | ||
|- README.md | ||
``` | ||
|
||
Let's go through each folder and its purpose: | ||
|
||
1. src: This is the main folder that contains the source code of the application. | ||
|
||
1. config: This folder holds configuration files, such as database configurations, environment variables, logging settings, etc. | ||
|
||
2. controllers: This folder contains the controllers responsible for handling HTTP requests, processing data, and interacting with services. | ||
|
||
3. models: This folder houses the data models or schema definitions for your application's data layer. | ||
|
||
4. routes: This folder contains the route definitions for different endpoints of your API or application. | ||
|
||
5. services: This folder holds the business logic or services that are responsible for processing data, interacting with models, and performing application-specific operations. | ||
|
||
6. utils: This folder contains utility files and helper functions that can be used across different parts of your application. | ||
|
||
2. tests: This folder is dedicated to storing your application's unit tests, integration tests, or any other test files. | ||
|
||
3. package.json: This file defines your project's metadata, dependencies, and scripts. | ||
|
||
4. .env: This file is used to store environment-specific configuration variables. It is usually not committed to version control and can contain sensitive information like API keys or database credentials. | ||
|
||
5. index.js: This file serves as the entry point of your application. It typically sets up the server, establishes database connections, and initializes other essential components. | ||
```Coming soon``` | ||
|
||
# Configuration | ||
|
||
Configure the application and database details in ```.env``` or ```config``` files | ||
|
||
|
||
> **Note**: | ||
Configuration values configured in ```.env``` has the first priority, if you need to use the config.js values then skip those keys on ```.env``` file | ||
Configure the application and database details in ```.env```file | ||
|
||
|
||
|
||
```bash title=".env" | ||
NODE_ENV=dev | ||
|
||
PORT=PORT_TO_RUN | ||
|
||
|
||
SOCKET_CORS_ORIGIN='http://localhost:3000' | ||
|
||
# URL of the Mongo DB | ||
MONGODB_URI="CONNECTION_STRING" | ||
|
||
SEARCH_API_KEY=GOOGLE_SEARCH_API_KEY | ||
PORT=8000 | ||
|
||
TELEGRAM_BOT_TOKEN="TELEGRAM_BOT_TOKEN" | ||
MONGODB_URL="mongodb://localhost:27017/sparkportal" | ||
|
||
# SMTP credentials | ||
[email protected] | ||
SMTP_HOST='smtp.zoho.com' | ||
SMTP_PORT=465 | ||
[email protected] | ||
SMTP_PASSWORD= | ||
JWT_SECRET='nilajs' | ||
|
||
PM2_LOGS_DIRECTORY='/Users/siva/.pm2/logs/npm-start-out.log' | ||
PM2_LOGS_USERNAME='admin' | ||
PM2_LOGS_PASSWORD='admin' | ||
|
||
``` | ||
|
||
``` | ||
|-src | ||
|--config | ||
|---app.config.js | ||
|---db.config.js | ||
``` | ||
|
||
|
||
```js title="app.config.js" | ||
export const appConfig = { | ||
// application name inside the project | ||
NAME : env.APP_NAME || 'Application name', | ||
|
||
NODE_ENV : env.NODE_ENV || 'development', | ||
PORT : env.PORT || '8080', | ||
|
||
SMTP_EMAIL_FROM : env.SMTP_EMAIL_FROM || '[email protected]', | ||
SMTP_HOST : env.SMTP_HOST || 'smtp.zoho.com', | ||
SMTP_PORT : env.SMTP_PORT || 465, | ||
SMTP_USERNAME : env.SMTP_USERNAME || '[email protected]', | ||
SMTP_PASSWORD : env.SMTP_PASSWORD || '', | ||
|
||
|
||
TELEGRAM_BOT_TOKEN : env.TELEGRAM_BOT_TOKEN || '', | ||
|
||
API_RATE_LIMIT_TIME : 15, // 15 minutes | ||
API_RATE_LIMIT : 100, // 100 requests for every 15 minutes | ||
|
||
LOG_DIRECTORY: 'logs', | ||
|
||
PM2_LOGS_DIRECTORY : env.PM2_LOGS_DIRECTORY || '/Users/siva/.pm2/logs/npm-start-out.log', | ||
PM2_LOGS_USERNAME: env.PM2_LOGS_USERNAME || 'admin', | ||
PM2_LOGS_PASSWORD: env.PM2_LOGS_PASSWORD || 'admin', | ||
} | ||
``` | ||
BCRYPT_SALT_ROUND=10 | ||
|
||
```js title="db.config.js" | ||
export const dbConfig = { | ||
|
||
MONGODB_URI : env.MONGODB_URI || '', | ||
SWAGGER_USERNAME=admin | ||
SWAGGER_PASSWORD=admin | ||
|
||
CONNECTION_OPTIONS : { | ||
useNewUrlParser: true, | ||
useUnifiedTopology: true | ||
} | ||
} | ||
``` | ||
|
||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.