{"id":19723977,"url":"https://github.com/vs4vijay/jera","last_synced_at":"2025-09-12T19:37:52.995Z","repository":{"id":38184147,"uuid":"304944003","full_name":"vs4vijay/JERA","owner":"vs4vijay","description":"A Microservice in NodeJS, TypeScript, Express, and Oracle","archived":false,"fork":false,"pushed_at":"2025-08-31T10:23:46.000Z","size":702,"stargazers_count":2,"open_issues_count":11,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-31T12:22:21.115Z","etag":null,"topics":["api","express","http-api","javascript","microservice","nodejs","oracle","rest-api","restful-api","starter-kit","starter-project","starter-template","typedi","typeorm","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vs4vijay.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2020-10-17T18:31:21.000Z","updated_at":"2025-07-29T19:06:18.000Z","dependencies_parsed_at":"2023-12-20T10:22:22.357Z","dependency_job_id":"c6705522-3d9d-4419-af00-3787f2504ea7","html_url":"https://github.com/vs4vijay/JERA","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/vs4vijay/JERA","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vs4vijay%2FJERA","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vs4vijay%2FJERA/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vs4vijay%2FJERA/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vs4vijay%2FJERA/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vs4vijay","download_url":"https://codeload.github.com/vs4vijay/JERA/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vs4vijay%2FJERA/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274864527,"owners_count":25364232,"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","status":"online","status_checked_at":"2025-09-12T02:00:09.324Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["api","express","http-api","javascript","microservice","nodejs","oracle","rest-api","restful-api","starter-kit","starter-project","starter-template","typedi","typeorm","typescript"],"created_at":"2024-11-11T23:24:06.981Z","updated_at":"2025-09-12T19:37:52.934Z","avatar_url":"https://github.com/vs4vijay.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JERA\n\nA Microservice in NodeJS, TypeScript, Express, and Oracle\n\nExpress + Routing-Controllers + TypeScript + TypeORM + TypeDI\n\n---\n\n## Installation\n\n```shell\nnpm install\n```\n\n- Create `.env` file from `.env.example` and populate environment variables\n\n---\n\n## Running\n\n```shell\n# Build and Run\nnpm start\n\n# Run on local machine with watcher\nnpm run start:dev\n```\n\n---\n\n## Features\n\n- [x] TypeScript\n- [x] Depedency Injection of Services, Repositories, Controllers\n- [x] Modular App.ts\n- [x] Properly structured codebase models, repositories, services, controllers, migrations etc.\n- [x] ORM Migrations used for maintaining database schemas\n- [x] Follows pure REST APIs\n- [x] Input validations\n- [x] Use of `.env` file\n- [x] Git pre-commit hooks setup\n- [x] Linting and Standard Formatting\n- [x] Added system metadata like createdAt, updatedAt\n- [x] Use of DTOs\n- [x] Added audit log like createdBy, updatedBy\n- [x] isActive\n- [x] uuid as primary key\n- [x] Soft Delete Options\n- [x] Pagination\n- [ ] Structured Logging\n- [ ] Unit Testing\n- [ ] Authentication\n- [ ] Authorization\n- [ ] Error Handling and Generic Error Middleware\n- [ ] Search Framework\n- [ ] AbstractService or interface Service\n- [ ] Graceful Shutdown\n- [x] Containerized with Docker\n\n---\n\n## Libraries Used\n\n- NodeJS with TypeScript\n  - ts-node and ts-node-dev for running on local machine\n- Express Framework\n- TypeORM - ORM Tool to interact with Database\n- TypeDI - Dependency Injection library (https://github.com/typestack/typedi)\n- routing-controllers - For Defining Routes in elegent way (https://github.com/typestack/routing-controllers)\n- class-validator - For input validations (https://github.com/typestack/class-validator)\n- class-transformer - For transforming objects (https://github.com/typestack/class-transformer)\n- dotenv - Use Environment Variables from .env file\n- ESLint - For Linting the ES and TypeScript codebase\n  - `ext install dbaeumer.vscode-eslint`\n- Prettier - For Formatting Standard (https://eslint.org/docs/user-guide/getting-started)\n  - `ext install esbenp.prettier-vscode`\n- Husky - https://github.com/typicode/husky\n- lint-staged - https://github.com/okonet/lint-staged\n\n---\n\n## Development\n\n- Create an entity: `npm run typeorm -- entity:create -n User`\n- Generate migration: `npm run typeorm -- migration:generate -n CreateUser`\n- Run the migrations: `npm run typeorm -- migration:run`\n\nNotes:\n\n- Migration name pattern: Add\u003cfield\u003eTo\u003cEntity\u003e\n  - AddLastNameToUser\n  - UpdateEmailToEmployee\n\n---\n\n### Development Guidelines\n\n- Make use of `index.ts` in folder which has multiple files\n\n---\n\n### Development Notes\n\n```javascript\n\ncurl -s localhost:9000/api/v1/users | jq\n\ncurl -s -H 'Content-Type:application/json' localhost:9000/api/v1/users -d '{\"name\": \"1111\"}' | jq\n\ncurl -s -H 'Content-Type:application/json' -X PUT localhost:9000/api/v1/users/a14040c8-4016-401b-98db-37619ae5a6fc -d '{\"name\": \"222 - updated\"}' | jq\n\ncurl -s localhost:9000/api/v1/users/7f5e8690-6be0-42ba-91a3-126e49723bc1 -X DELETE\n\n  private initMiddlewares(): void {\n    this.app.use(bodyParser.json());\n    this.app.use(bodyParser.urlencoded({ extended: false }));\n  }\n\n\n\"oracledb\": \"^1.13.1\",\n\nconfig: any to some type?\n\n\nController -\u003e Service -\u003e Repository -\u003e Model -\u003e DB\n\n\nTypeORM:\n- `save` method does both creation and updation\n\n@OneToMany(type =\u003e SubCategory, subcategoy =\u003e subcategoy.Category)\nSubCategories: SubCategory[];\n\n@ManyToOne(type =\u003e Category, category =\u003e category.SubCategories)\n@JoinColumn({name: \"CategoryId\"})\nCategory: Category;\n\n\n\nnpm install --save-dev husky\n{\n    \"husky\": {\n        \"hooks\": {\n        \"pre-commit\": \"yarn lint\"\n        }\n    }\n}\n\nhttps://github.com/okonet/lint-staged\nhttps://github.com/azz/pretty-quick\n\nhttps://sourcelevel.io/blog/how-to-setup-eslint-and-prettier-on-node\n\nhttps://github.com/albinojunior/node-crudapi-ts/blob/master/src/app.ts\n\nmkdir -p /opt/oracle\ncd /opt/oracle\nwget https://download.oracle.com/otn_software/linux/instantclient/instantclient-basic-linuxx64.zip\nunzip instantclient-basic-linuxx64.zip\n\napt-get install -y libaio1\n\nsudo sh -c \"echo /opt/oracle/instantclient_19_9 \u003e /etc/ld.so.conf.d/oracle-instantclient.conf\"\nsudo ldconfig\n\nexport LD_LIBRARY_PATH=/opt/oracle/instantclient_19_9\n\n\nnode --require ts-node/register ./node_modules/typeorm/cli.js\n\nBaseController / AbstractController\n\nclass Config {\n  NODE_ENV: string;\n  DB: JSON;\n}\n\nimport { Request, Response } from \"express\";\ngetAll(@Req() request: Request, @Res() response: Response) {\n\n\nimport { useExpressServer } from \"routing-controllers\";\nlet express = require(\"express\");\nlet app = express();\napp.use();\nuseExpressServer(app, {\n  defaults: {\n    nullResultCode: 404\n  },\n  cors: true,\n  controllers: [__dirname + \"/controllers/*.js\"],\n  middlewares: [LoggingMiddleware, CustomErrorHandler],\n});\napp.listen(3000);\n\n//\nclass Pagination {\n    @IsPositive()\n    limit: number;\n\n    @IsPositive()\n    offset: number;\n}\n@QueryParam(\"limit\") limit: number\ngetUsers(@QueryParams() pagination: Pagination)\n@HeaderParam(\"authorization\") token: string\n@ContentType(\"text/csv\")\n@Location(\"http://github.com\")\n@Redirect(\"http://github.com\")\n@Render(\"index.html\")\n@HttpCode(201)\n@OnUndefined(404)\ngetOne(@Param(\"id\") id: number) {\n    return userRepository.findOneById(id);\n}\n\nimport { HttpError } from \"routing-controllers\";\nexport class UserNotFoundError extends HttpError {\n    constructor() {\n        super(404, \"User not found!\");\n    }\n}\n@OnUndefined(UserNotFoundError)\n\nthrow new UserNotFoundError()\n\n@UseBefore()/@UseAfter()\n\n@Middleware({ type: \"before\" }) // Global middleware\nexport class MyMiddleware implements ExpressMiddlewareInterface {\n  use(request: any, response: any, next?: (err?: any) =\u003e any): any {\n    console.log(\"do something...\");\n    next();\n  }\n}\n\nimport { Middleware, ExpressErrorMiddlewareInterface } from \"routing-controllers\";\n@Middleware({ type: \"after\" })\nexport class CustomErrorHandler implements ExpressErrorMiddlewareInterface {\n  error(error: any, request: any, response: any, next: (err: any) =\u003e any) {\n    console.log(\"do something...\");\n    next();\n  }\n}\n\n@Authorized()\nauthorizationChecker: async (action: Action, roles: string[]) =\u003e {...}\n\n@CurrentUser()\ncurrentUserChecker: async (action: Action) =\u003e {...}\n\nimport { createParamDecorator } from \"routing-controllers\";\n\n\nprocess.on('SIGINT', () =\u003e {\n  // Gracefully\n}\n\n\n\nmigrationsRun: true\n\n\nconst limit = request.params.pageSize;\n\nconst skip = request.params.pageNo * limit;\n\nconst [userListByPage, totalUsersCount] = await this.userRepository.createQueryBuilder(“user”).skip(skip).take(limit).getManyAndCount();\n\n\n.where(`user.address ::jsonb @\u003e \\'{\"state\":\"${query.location}\"}\\'`)\n\njest --init\n\n\nAuthentication using OIDC\n- Okta\n  - package - @okta/oidc-middleware\n    - Routes - oidc.router\n    - Middleware - oidc.ensureAuthenticated()\n    - Logout - oidc.forceLogoutAndRevoke()\n  - Login - https://developer.okta.com/login/\n  - Issuer URL - https://dev-04022784.okta.com\n  - Client ID - 0oa5xan98da2ngFCf5d6\n  - Client Secret -\n- Auth0\n  - package - express-openid-connect\n    - Routes - auth(authConfig)\n    - Middleware - requiresAuth()\n  - Login - https://auth0.auth0.com\n  - Issuer URL - https://vs4vijay.auth0.com\n  - Client ID - g2m6mwjswZap6TNKlrCb6isGUvw6D9Sh\n  - Client Secret -\n- Playground - https://openidconnect.net/\n- Libraries\n  - https://github.com/panva/node-openid-client\n  - https://github.com/jaredhanson/passport\n- Providers\n  - https://github.com/panva/node-oidc-provider\n  - ORY Hydra - https://github.com/ory/hydra\n  - Keycloak - https://github.com/keycloak/keycloak\n  - https://github.com/dexidp/dex\n  - https://github.com/apereo/cas\n  - Azure AD\n  - Ping Identity\n  - OneLogin\n  - LoginRadius\n  - OpenAM ForgeRock\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvs4vijay%2Fjera","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvs4vijay%2Fjera","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvs4vijay%2Fjera/lists"}