{"id":20087054,"url":"https://github.com/ahoward2/easier-nest-server","last_synced_at":"2026-05-13T03:08:56.347Z","repository":{"id":104287546,"uuid":"487404288","full_name":"ahoward2/easier-nest-server","owner":"ahoward2","description":"Functional programming approach to a Nest JS server. ƛ","archived":false,"fork":false,"pushed_at":"2022-05-03T06:14:47.000Z","size":417,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-02T14:47:15.665Z","etag":null,"topics":["functional-programming","nestjs","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/ahoward2.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":"2022-04-30T23:38:15.000Z","updated_at":"2022-05-03T01:31:58.000Z","dependencies_parsed_at":null,"dependency_job_id":"0e9116db-2763-47a0-9cd0-e355bfe357ef","html_url":"https://github.com/ahoward2/easier-nest-server","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ahoward2/easier-nest-server","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahoward2%2Feasier-nest-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahoward2%2Feasier-nest-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahoward2%2Feasier-nest-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahoward2%2Feasier-nest-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ahoward2","download_url":"https://codeload.github.com/ahoward2/easier-nest-server/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahoward2%2Feasier-nest-server/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32965873,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-12T23:30:32.555Z","status":"online","status_checked_at":"2026-05-13T02:00:07.132Z","response_time":115,"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":["functional-programming","nestjs","typescript"],"created_at":"2024-11-13T16:03:44.827Z","updated_at":"2026-05-13T03:08:56.312Z","avatar_url":"https://github.com/ahoward2.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"![architecture image](./static/architecture.png)\n\n# Easier Nest Server\n\n## Description\n\nAn attempt at simplifying the API route creation of [Nest](https://github.com/nestjs/nest). Focus on writing handler functions instead of providers. This model is friendly for people more comfortable with functional programming than OOP.\n\n## The Design\n\nNest servers are generally built in an object oriented way. The 3 core components of Nest servers are:\n\n- [Controllers](https://docs.nestjs.com/controllers)\n- [Providers](https://docs.nestjs.com/providers)\n- [Modules](https://docs.nestjs.com/modules)\n\nIn this project, we keep 1 Controller `ApiController` that manages all api routes which are simple handler functions. These handler functions are replacements for `Providers`.\n\n### ApiController\n\nInstead of writing many controllers for many routes, we rely on one controller for all routes. Also, Nest ships with [Decorators](https://docs.nestjs.com/controllers#full-resource-sample) to define different CRUD operations in controllers. In this case, we rely on 1 of those Decorators - the `@All()` Decorator which will handle all CRUD operations for a given route. This way, we offload the conditional logic to the handler function.\n\n```ts\n// src/api/api.controller.ts\n\nimport { All, Controller, Req, Res } from '@nestjs/common';\nimport { routeConfig as helloConfig } from './routes/hello/hello';\nimport { routeConfig as helloParamConfig } from './routes/hello/nameParam';\n\n/**\n * This is the core controller for API routes. To create routes for the API,\n * simply create a new route under the routes folder, create an async\n * handler function, and export a routeConfig object that contains the path for the route\n * and the handler function. Import it into this file and add it under the\n * ApiController class.\n */\n\n@Controller('api')\nexport class ApiController {\n  @All(helloConfig.path)\n  async executeHelloHandler(@Req() req, @Res() res) {\n    return helloConfig.handler(req, res);\n  }\n\n  @All(helloParamConfig.path)\n  async executeHelloNameHandler(@Req() req, @Res() res) {\n    return helloParamConfig.handler(req, res);\n  }\n}\n```\n\nIn the `ApiController`, we're importing `routeConfig` objects from route files. Here are the two routes used:\n\n```ts\n// src/api/routes/hello/hello.ts\n\nasync function handler(req, res) {\n  if (req.method === 'GET') {\n    return res.json({ url: req.url });\n  }\n}\n\nexport const routeConfig = {\n  path: '/hello',\n  handler: handler,\n};\n```\n\n```ts\n// src/api/routes/hello/nameParam.ts\n\nimport axios from 'axios';\n\nasync function handler(req, res) {\n  if (req.method === 'GET') {\n    const { data } = await axios.get(\n      `https://api.github.com/users/${req.params.name}`,\n    );\n    return res.json(data);\n  }\n}\n\nexport const routeConfig = {\n  path: '/hello/:name',\n  handler: handler,\n};\n```\n\n## Installation\n\n```bash\n$ yarn install\n```\n\n## Running the app\n\n```bash\n# development\n$ yarn start\n\n# watch mode\n$ yarn start:dev\n\n# production mode\n$ yarn start:prod\n```\n\n## Test\n\n```bash\n# unit tests\n$ yarn test\n\n# e2e tests\n$ yarn test:e2e\n\n# test coverage\n$ yarn test:cov\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fahoward2%2Feasier-nest-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fahoward2%2Feasier-nest-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fahoward2%2Feasier-nest-server/lists"}