{"id":16759041,"url":"https://github.com/hardeep-bit/express-app-generator","last_synced_at":"2025-06-19T00:05:14.433Z","repository":{"id":95778216,"uuid":"95729246","full_name":"hardeep-bit/express-app-generator","owner":"hardeep-bit","description":"NodeJs Server with ExpresssJs - Routing, Responses, Logger","archived":false,"fork":false,"pushed_at":"2020-11-18T11:25:57.000Z","size":21,"stargazers_count":8,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-31T01:42:25.900Z","etag":null,"topics":["crud","generic-responses","middleware","router"],"latest_commit_sha":null,"homepage":"","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/hardeep-bit.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":"2017-06-29T02:12:13.000Z","updated_at":"2023-08-14T15:41:31.000Z","dependencies_parsed_at":null,"dependency_job_id":"68aaf132-9d66-4215-963a-1bb93bd1ab54","html_url":"https://github.com/hardeep-bit/express-app-generator","commit_stats":{"total_commits":29,"total_committers":2,"mean_commits":14.5,"dds":0.4137931034482759,"last_synced_commit":"a16848f6266c0215f3c04e5d984084e3b0b315dc"},"previous_names":["hardeep-bit/express-app-generator","hardy12994/express-app-generator"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/hardeep-bit/express-app-generator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hardeep-bit%2Fexpress-app-generator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hardeep-bit%2Fexpress-app-generator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hardeep-bit%2Fexpress-app-generator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hardeep-bit%2Fexpress-app-generator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hardeep-bit","download_url":"https://codeload.github.com/hardeep-bit/express-app-generator/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hardeep-bit%2Fexpress-app-generator/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260654642,"owners_count":23042675,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["crud","generic-responses","middleware","router"],"created_at":"2024-10-13T04:07:05.824Z","updated_at":"2025-06-19T00:05:09.404Z","avatar_url":"https://github.com/hardeep-bit.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n[![Express Logo](https://i.cloudup.com/zfY6lL7eFa-3000x3000.png)](http://expressjs.com/)\n\n### Generate NodeJs Express App\n\n#### Installation -\n\n``\n    npm install express-app-generator --save\n``\n\nTo make node app with express framework, many things are needed i.e -\n- Environment where the server is made.\n- Generic Responses are set, in which form their is need.\n- Routing Generic need to set.\n- Logging where ther is a need.\n\nNow what this Module Provide to us -\n- An Enviroment where server is Run on Any Perticular Port.\n- A Generic Router with unlimited middleware can be set.\n- Give Generic Response as Data ,Items etc.\n- Obvisously a Logger which helps to Log things.\n\nThe generated app Provide us some default express Features like -\n- `bodyParser.json();`\n- `bodyParser.urlencoded({extended: true});`\n- `bodyParser({ limit: '50mb', keepExtensions: true })`\n- `'view engine', 'ejs'`\n- express static path `public` folder in root of app folder\n- if port is null it use default port `3000`\n\n\n## Generate Express App\n ```sh\nlet appGenrator=require('express-app-generator');\nappGenrator.generate(3789, 'src/api', function(err,app){\n    if(err){\n       return console.log(err);\n    }\n    // your express app is Ready to use\n    //you can check this on http://localhost:3789\n    console.log(app)\n});\n```\n\nIf you want to change express properties , \nyou can change it by update `app.use()` or `app.set()`;\n\n## Routing\n- Clean and Easy To Use.\n- **Required Things** \n    \n    \u003e Provide the API path (where all the API's are kept) from the root of APP.\n      This will be string like `'src/api' and \n      in this `api` folder all the .js files will be like \n      `users.js` not `user.js` , `employees.js` not `employee.js` \n      which means `s` or `es` sufix is must.\n    \n    \u003e The `logs` folder is required ,this folder is use for \n      logging the logs in json files ,which we get as in console\n\n\n- This Router Provides Simple CRUD Mechanism . In which Combinations of Arrays and Objects are use To Build it.\n- `appRouter` method  which is present in app generator helps to make Routing in Flexible way.\n\n*Lets get started for Routing* -\n**REST or CRUD**\n```sh\n    let api= app.appRouter; \n    //app is Express genrated app (above define how to get it)\n    api.model('users')\n        .register('REST', [ authentication ]);\n```\nThis will make URL as http://localhost:3789/api/users .\n\nWe can use `REST` or `CRUD` Keyword to get `create,update,delete,get,search` these \nmethods ready to use but for this,\nYou must have all these methods present in `/api/users.js` file .\n\nThe array which is present just after the `REST` is use for middlewares. \nSuppose I want to make authentication every time so the function of \nauthentication will be pass in the middleware Array.\n\nThings `REST` Or `CRUD` Gives -\n\n- If the Request is for **`POST`** then it go for `expots.create=(req,res)=\u003e{};`\n\n- If the Request is for **`GET`** then it go for `expots.get=(req,res)=\u003e{};`\nhttp://localhost:3789/api/users/:id\n\n- If the Request is for **`GET`** then it go for `expots.search=(req,res)=\u003e{};`\n\nhttp://localhost:3789/api/users\nHere many query params `?` can use.\n\n- If the Request is for **`PUT`** then it go for `expots.update=(req,res)=\u003e{};`\n\n- If the Request is for **`DELETE`** then it go for `expots.delete=(req,res)=\u003e{};`\n\n\n**Note** - All the the Middleware fuctions must have parameters `req,res,next` where \nreq,res are request response express generated objects and next is the \ncallback function which will call when one middleware work is DONE and\nit will go to next middleware function (if present) in that array and perform same,\nthen go the main function in the `users.js`. \n\n**User Define Requests** -\n\n- In register `action` and `method` is Requied\n- fiter for One Middleware and filters for Multiple \n- For Single Request -\n```sh\n    api.model('users')\n        .register({\n            action: 'GET',\n            method: 'get', // method must present inside users.js\n            url: '/:id',\n            filters: [authentication] //middlewares \n        });\n        \n        // URL will be -\n        // http://localhost:3789/api/users/:id\n```\n\n\n- For Multiple Requests -\n\n```sh \n api.model('users')\n        .register([{\n            action: 'POST',\n            method: 'create'\n        },{\n            action: 'POST',\n            method: 'createWithProfile',\n            url: '/withProfile',\n            filter: authentication\n        }, {\n            action: 'POST',\n            method: 'importer',\n            url: '/importer',\n            filter: authentication\n        }, {\n            action: 'POST',\n            method: 'createWhenSignIn',\n            filter: authentication\n        }, {\n            action: 'PUT',\n            method: 'update',\n            url: '/:id',\n            filters: [authentication, groupCode]\n        }, {\n            action: 'GET',\n            method: 'get',\n            url: '/:id',\n            filters: [authentication, groupCode]\n        }, {\n            action: 'GET',\n            method: 'search',\n            filters: [authentication, groupCode]\n        }, {\n            action: 'GET',\n            method: 'searchInGroup',\n            url: '/from/group',\n            filters: [authentication, groupCode]\n        }, {\n            action: 'GET',\n            method: 'getLeader',\n            url: '/get/leader/:id',\n            filters: [authentication, groupCode]\n        }]);\n```\n\n**Note**: `api` keyword in URL is Constant all over the Router.\nSo your base url will be http://localhost:3789/api/ .\n\n## Responses\n\nTheir are Four Types of Responses\nAll the Responses is of `status Code is 200` . \n- data\n    - It can take one or two params `data,message`,\n     `data` is mandatory. \n    - It is use as -\n\n    ```sh\n    res.data({\n        name:\"Leo\",\n        age:21\n    });\n    \n     //res which you get from any query\n    ```\n\n    - This will give Response -\n    ```sh\n    {\n        \"isSuccess\":true,\n        \"data\":{\n            \"name\":\"Leo\",\n            \"age\":21\n            }\n    }\n    ```\n- page\n    - It can take one or two params `items, pageSize, pageNo, totalRecordsCount`\n     `items` is mandatory.\n    - Can also use for Paginations.\n    - It is use as -\n\n    ```sh\n    res.page([{\n        name:\"Leo\",\n        age:21\n    },{\n        name:\"Hardy\",\n        age:22\n    }]);\n    \n     //res which you get from any query\n    ```\n    \n    - This will give Response -\n    ```sh\n    {\n        \"isSuccess\":true,\n        \"items\":[{\n             \"name\":\"Leo\",\n             \"age\":21\n         },{\n            \"name\":\"Hardy\",\n            \"age\":22\n         }],\n         pageSize:2\n    }\n    ```\n- success\n    - It can takes one params `message`, it is mandatory.\n    - Can Use for Sending Successful Signature message.\n    - It is use as -\n\n    ```sh\n    res.success(`user successfully deleted`);\n    ```\n    \n    - This will give Response -\n    ```sh\n    {\n        \"isSuccess\":true,\n        \"message\":\"user successfully deleted\"\n    }\n    ```\n- failure\n    - It can takes two params `error, message`,\n     `error` it is mandatory.\n    - Can Use for Sending Error Signature message.\n    - It is use as -\n\n    ```sh\n    res.failure(`user Hardy already present`);\n    ```\n    \n    - This will give Response -\n    ```sh\n    {\n        \"isSuccess\":false,\n        \"message\":\"user Hardy already present\"\n    }\n    ```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhardeep-bit%2Fexpress-app-generator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhardeep-bit%2Fexpress-app-generator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhardeep-bit%2Fexpress-app-generator/lists"}