{"id":20796634,"url":"https://github.com/gotocva/nilajs-boilerplate","last_synced_at":"2026-04-08T18:07:02.548Z","repository":{"id":273059241,"uuid":"885157137","full_name":"gotocva/nilajs-boilerplate","owner":"gotocva","description":"NilaJS is a REST api framework with expressive, elegant syntax. A web framework provides a structure and starting point for creating your REST api, allowing you to focus on creating something amazing while we sweat the details.","archived":false,"fork":false,"pushed_at":"2024-11-08T04:05:17.000Z","size":25,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-04T07:42:12.129Z","etag":null,"topics":["express","expressjs","mongodb","mongoose","node-mongodb","nodejs","rest-api","restful-api"],"latest_commit_sha":null,"homepage":"https://nilajs.in/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gotocva.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-08T04:04:34.000Z","updated_at":"2024-11-09T11:03:26.000Z","dependencies_parsed_at":"2025-01-18T11:39:05.078Z","dependency_job_id":null,"html_url":"https://github.com/gotocva/nilajs-boilerplate","commit_stats":null,"previous_names":["gotocva/nilajs-boilerplate"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/gotocva/nilajs-boilerplate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gotocva%2Fnilajs-boilerplate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gotocva%2Fnilajs-boilerplate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gotocva%2Fnilajs-boilerplate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gotocva%2Fnilajs-boilerplate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gotocva","download_url":"https://codeload.github.com/gotocva/nilajs-boilerplate/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gotocva%2Fnilajs-boilerplate/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31567358,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-08T14:31:17.711Z","status":"ssl_error","status_checked_at":"2026-04-08T14:31:17.202Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["express","expressjs","mongodb","mongoose","node-mongodb","nodejs","rest-api","restful-api"],"created_at":"2024-11-17T16:28:27.596Z","updated_at":"2026-04-08T18:07:02.510Z","avatar_url":"https://github.com/gotocva.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Nilajs\n\nNilajs is a Node.js application framework powered by the **Express.js** designed for building scalable and maintainable RESTful APIs. This project follows a modular architecture, where each feature (or module) has its own set of files, making the application easy to extend and maintain.\n\n## Table of Contents\n\n- [Installation](#installation)\n- [Folder Structure](#folder-structure)\n- [Features](#features)\n- [Usage](#usage)\n- [License](#license)\n\n---\n\n## Installation\n\nTo get started with Nilajs, follow these steps:\n\n### 1. Clone the repository:\n```bash\ngit clone https://github.com/yourusername/nilajs.git\n```\n\n### 2. Install dependencies:\nMake sure you have **Node.js** and **npm** installed. Then, navigate to the project directory and run:\n\n```bash\ncd nilajs\nnpm install\n```\n\n### 3. Set up environment variables:\nCreate a `.env` file at the root of the project directory with the necessary environment variables (e.g., for database connections, API keys).\n\n### 4. Start the development server:\n```bash\nnpm run dev\n```\n\n---\n\n## Folder Structure\n\nNilajs follows a modular folder structure to help organize code logically. Below is an explanation of each folder and its purpose.\n\n```\nnilajs/\n│\n├── src/\n│   ├── app/\n│   │   ├── \u003cmodule_name\u003e/\n│   │   │   ├── controllers/\n│   │   │   │   └── \u003cmodule_name\u003eController.js\n│   │   │   ├── messages/\n│   │   │   │   └── \u003cmodule_name\u003eMessages.js\n│   │   │   ├── middlewares/\n│   │   │   │   └── \u003cmodule_name\u003eMiddleware.js\n│   │   │   ├── models/\n│   │   │   │   └── \u003cmodule_name\u003eModel.js\n│   │   │   ├── routes/\n│   │   │   │   └── \u003cmodule_name\u003eRouter.js\n│   │   │   ├── services/\n│   │   │   │   └── \u003cmodule_name\u003eService.js\n│   │   │   └── \u003cmodule_name\u003eService.js (optional, generic)\n│   │   ├── config/\n│   │   │   └── config.js\n│   │   ├── middlewares/\n│   │   │   └── authMiddleware.js\n│   │   ├── routes/\n│   │   │   └── index.js\n│   │   ├── utils/\n│   │   │   └── HttpUtil.js\n│   │   │   └── ResponseUtil.js\n│   ├── server.js\n│   ├── app.js\n│   └── package.json\n├── .env\n└── README.md\n```\n\n### `src/app/` Directory\n\nThis directory holds the application's business logic, broken down into modules. Each module consists of the following parts:\n\n#### 1. `\u003cmodule_name\u003e/controllers/`\n- **Purpose**: Controllers handle incoming requests, process them (often using services), and send back a response.\n- **Example**: `\u003cmodule_name\u003eController.js` contains methods like `create`, `list`, `update`, `delete`, and `get`, typically interacting with the service layer to perform the business logic.\n\n#### 2. `\u003cmodule_name\u003e/messages/`\n- **Purpose**: Contains message constants for the module. It’s used for API responses and error messages.\n- **Example**: `\u003cmodule_name\u003eMessages.js` might contain success and error messages like:\n    ```js\n    export const \u003cModuleName\u003eMessages = {\n        OK: 'Success',\n        \u003cMODULE_NAME\u003e_CREATED: '\u003cModuleName\u003e created successfully',\n        BAD_REQUEST: 'Bad request',\n    };\n    ```\n\n#### 3. `\u003cmodule_name\u003e/middlewares/`\n- **Purpose**: Middlewares are used to perform pre-processing on requests, such as validation, authentication, or logging.\n- **Example**: `\u003cmodule_name\u003eMiddleware.js` could have authentication middleware that checks the JWT token before allowing access to certain routes.\n\n#### 4. `\u003cmodule_name\u003e/models/`\n- **Purpose**: Defines the Mongoose schema for MongoDB collections.\n- **Example**: `\u003cmodule_name\u003eModel.js` contains the schema definition:\n    ```js\n    import mongoose from 'mongoose';\n    \n    const \u003cmodule_name\u003eSchema = new mongoose.Schema({\n        name: String,\n        description: String,\n    });\n    \n    export const \u003cModuleName\u003e = mongoose.model('\u003cModuleName\u003e', \u003cmodule_name\u003eSchema);\n    ```\n\n#### 5. `\u003cmodule_name\u003e/routes/`\n- **Purpose**: Defines the API routes for the module.\n- **Example**: `\u003cmodule_name\u003eRouter.js` could define the routes like `GET`, `POST`, `PUT`, `DELETE` for handling various requests for that module.\n\n#### 6. `\u003cmodule_name\u003e/services/`\n- **Purpose**: Services contain the core business logic of the module, including interacting with the database models.\n- **Example**: `\u003cmodule_name\u003eService.js` contains methods like `create`, `list`, `update`, etc., for interacting with the database.\n\n### `src/config/` Directory\n\nContains the application’s configuration files.\n\n- **config.js**: Holds general configuration settings (e.g., database URL, JWT secret).\n\n### `src/middlewares/` Directory\n\nGlobal middlewares that can be applied across the application.\n\n- **authMiddleware.js**: Middleware for handling authentication, usually checking for a valid JWT token.\n\n### `src/routes/` Directory\n\nContains the main routing logic for the entire application.\n\n- **index.js**: Central file where you combine all the module routes and apply them to the Express app.\n\n### `src/utils/` Directory\n\nContains utility functions that can be shared across the app.\n\n- **HttpUtil.js**: Utility for HTTP status codes.\n- **ResponseUtil.js**: Utility for formatting consistent API responses.\n\n### `src/server.js`\n\nThis file initializes the server and connects to the database.\n\n```js\nimport express from 'express';\nimport mongoose from 'mongoose';\nimport routes from './app/routes';\n\nconst app = express();\n\nmongoose.connect(process.env.DB_URL, { useNewUrlParser: true, useUnifiedTopology: true })\n    .then(() =\u003e console.log('Database connected'))\n    .catch((err) =\u003e console.error('Database connection error:', err));\n\napp.use(express.json());\napp.use('/api', routes); // Load the API routes\n\napp.listen(process.env.PORT, () =\u003e {\n    console.log(`Server running on port ${process.env.PORT}`);\n});\n```\n\n### `src/app.js`\n\nSets up the Express app and middleware configurations.\n\n```js\nimport express from 'express';\nimport cors from 'cors';\nimport helmet from 'helmet';\nimport { errorHandler } from './utils/ResponseUtil';\n\nconst app = express();\n\napp.use(cors());      // Enable Cross-Origin Resource Sharing\napp.use(helmet());    // Set security headers\napp.use(express.json());\n\napp.use(errorHandler); // Global error handler middleware\n\nexport default app;\n```\n\n---\n\n## Features\n\n- **Modular Architecture**: Each module has its own controller, model, service, and routes, making the codebase easy to maintain and extend.\n- **Middlewares**: Pre-configured for handling authentication, logging, and validation.\n- **RESTful API**: Organized API routes with standard HTTP methods.\n- **MongoDB Integration**: Built-in support for MongoDB with Mongoose for schema management.\n- **Scalability**: Easily extend the application by adding new modules with minimal changes to existing code.\n- **Error Handling**: Centralized error handling to provide consistent responses and logging.\n\n---\n\n## Usage\n\nOnce the application is set up, you can start building your own modules by following this structure. For example, to create a new module:\n\n1. Create a new directory for the module inside the `src/app/` directory.\n2. Inside the module directory, create the necessary files (`controllers`, `models`, `routes`, etc.) following the structure.\n\n---\n\n## License\n\nNilajs is released under the MIT License. See the [LICENSE](LICENSE) file for more details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgotocva%2Fnilajs-boilerplate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgotocva%2Fnilajs-boilerplate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgotocva%2Fnilajs-boilerplate/lists"}