{"id":15368006,"url":"https://github.com/ptariche/typescript-koa-mongoose-starter","last_synced_at":"2025-10-09T17:36:13.209Z","repository":{"id":54239376,"uuid":"188322011","full_name":"ptariche/typescript-koa-mongoose-starter","owner":"ptariche","description":"When Function found Type: A Starter with Koa and Mongoose in Typescript","archived":false,"fork":false,"pushed_at":"2021-03-01T22:40:21.000Z","size":1442,"stargazers_count":12,"open_issues_count":5,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-01T05:40:10.261Z","etag":null,"topics":["backend","joi","koa","koa2","mongoose","nodejs","rest-api","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/ptariche.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null}},"created_at":"2019-05-23T23:50:15.000Z","updated_at":"2022-10-05T08:16:30.000Z","dependencies_parsed_at":"2022-08-13T09:50:33.806Z","dependency_job_id":null,"html_url":"https://github.com/ptariche/typescript-koa-mongoose-starter","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/ptariche/typescript-koa-mongoose-starter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ptariche%2Ftypescript-koa-mongoose-starter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ptariche%2Ftypescript-koa-mongoose-starter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ptariche%2Ftypescript-koa-mongoose-starter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ptariche%2Ftypescript-koa-mongoose-starter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ptariche","download_url":"https://codeload.github.com/ptariche/typescript-koa-mongoose-starter/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ptariche%2Ftypescript-koa-mongoose-starter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279001871,"owners_count":26083197,"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-10-09T02:00:07.460Z","response_time":59,"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":["backend","joi","koa","koa2","mongoose","nodejs","rest-api","typescript"],"created_at":"2024-10-01T13:27:41.439Z","updated_at":"2025-10-09T17:36:13.193Z","avatar_url":"https://github.com/ptariche.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Typescript Koa Mongoose Starter\n\n[![Build Status](https://travis-ci.org/ptariche/typescript-koa-mongoose-starter.svg?branch=master)](https://travis-ci.org/ptariche/typescript-koa-mongoose-starter)\n\nTypescript Koa Mongoose Starter is the beginning of folks who want to play with Typescript in the backend\n\n# Why did I do this?\n\n  - I wanted to entertain the idea of possibly running Typescript for our backend at my job\n  - I haven't touched typescript in 6 years and wanted to see how much it has matured\n  - I recently played with Deno as I love Rust and ran into several issues \n\n# Challenges\n - Many libraries for the backend do not have types and some of the @types libraries are out of date\n - This increased my development time by a multiple of x3 of what would normally take me to develop\n - There wasn't any historical documents or documentation I could find for many of the node modules I normally use\n\n# Will I use Typescript in the Future for Node in the backend\n - Maybe\n\n----\n### Prerequisites\n\n- Docker (brew cask install docker on mac)\n- Mongo (The docker-compose uses Mongo:latest)\n- JQ (brew install jq on mac)\n- Node 10+\n\n### Environment Variables\n - Environment variables for local development are found in config.env\n - For Docker deployments they are found in deploy.env\n\n    ```\n    PORT=3000\n    MONGO_URI=mongodb://127.0.0.1:27017/test\n    JWT_SECRET=12345678900987654321zxTypeScript\n    APP_NAME=typescript-node-example\n    ```\n### Special Notes\nIf you wish to change the port in the env variable, make sure to change the ports inside the docker-compose file if you are using the docker-compose commands in the makefile or in package.json\n\n### Installation\nInstall the dependencies and devDependencies and start the server.\n\n```sh\n$ cd typescript-koa-mongoose-starter\n$ npm install\n$ npm start\n```\n\nFor production environments.. 0_o\n\n```sh\n$ npm install\n$ npm run compose-up\n```\n\n### Generate Documentation\nThe documentation is outputted in a documentation directory in the root directory.\n\n```sh\n$ npm run documentation\n```\n\n### Development\n\nThe service runs on port 3000 by default\n\nWant to contribute? Great! Make a Pr!\n\nOpen your favorite Terminal and run these commands.\n\n```sh\n$ npm run watch\n```\n\n#### Building for source\nTo release in javascript. The output is dumped in the dist folder:\n```sh\n$ npm run build\n```\n\n---\n## Documentation\n\n### Error Handling\n - If an error occurs that is not taken into account for the error bubbles up to the Koa Error Handleware middleware in the middleware directory, is caught and sent a 500.\n - Input validation responds with a 412 if not providated with the proper input\n \n### Swagger\n - Swagger routes can be added by utilizing https://github.com/zaaack/koa-joi-swagger although there isn't a type definition file\n \n### Endpoints\n\n* Note All Posts require `Content-Type: application/json`\n* Note All Authenticated posts require `Authorization Bearer \u003cJwtToken\u003e`\n\n##### /user - POST\n\nAn endpoint that has input and output validation that returns the following information. The password field should be stored in Mongo cryptographically hashed\n\n###### INPUT - JSON\n\n\n|                |Type                          \n|----------------|-------------------------------\n|first_name          |String           \n|last_name          | String\n|email          |String\n|password          |String\n\n###### Output - JSON\n\n|                |Type                          \n|----------------|-------------------------------\n|id | String          \n|first_name          |String           \n|last_name          | String\n|email          |String\n\n\n#### /login - POST\n\nAn endpoint that has input and output validation that returns the following information. This uses JWT Tokens.\n\n###### Input - JSON\n\n|                |Type                          \n|----------------|-------------------------------\n|email          |String           \n|password          | String\n\n###### Output - JSON\n\n\n|                |Type                          \n|----------------|-------------------------------\n|user_id | String          \n|token | String          \n\n#### /user/{user_id} - GET * Authenticated Route\n\nAn Authorization Header must be present with `Bearer \u003cjwtToken\u003e` returned from login.\nAn endpoint that returns the user object., and has output validation. This endpoint requires a valid JWT Token\n\n###### Output - JSON\n\n|                |Type                          \n|----------------|-------------------------------\n|id | String          \n|first_name          |String           \n|last_name          | String\n|email          |String\n\n##### /user/{user_id} - PUT\n\nAn Authorization Header must be present with `Bearer \u003cjwtToken\u003e` returned from login.\nAn endpoint that updates the input of a document and output validation that returns the following information.\n\n###### INPUT - JSON\n\n\n|                |Type                          \n|----------------|-------------------------------\n|first_name          |String           \n|last_name          | String\n\n\n###### Output - JSON\n\n|                |Type                          \n|----------------|-------------------------------\n|id | String          \n|first_name          |String           \n|last_name          | String\n|email          |String\n\n\n#### Testing\n* Uses Jest, Supertest, Chai and MongoDB Memory Server\n\n    ```sh\n    npm test\n    ```\n#### File Tree Source\n```\n-- src\n    |-- .gitignore\n    |-- .travis.yml\n    |-- CHANGELOG.md\n    |-- Dockerfile\n    |-- LICENSE\n    |-- README.md\n    |-- config.env\n    |-- deploy.env\n    |-- docker-compose.yml\n    |-- jest.config.js\n    |-- makefile\n    |-- package-lock.json\n    |-- package.json\n    |-- tsconfig.json\n    |-- tslint.json\n    |-- version.sh\n    |-- src\n    |   |-- db.ts\n    |   |-- index.ts\n    |   |-- router.ts\n    |   |-- server.ts\n    |   |-- controller\n    |   |   |-- blackhole.ts\n    |   |   |-- login.ts\n    |   |   |-- health.ts\n    |   |   |-- user.ts\n    |   |-- lib\n    |   |   |-- jwt.ts\n    |   |-- middleware\n    |   |   |-- index.ts\n    |   |-- model\n    |   |   |-- user.ts\n    |   |-- router\n    |   |   |-- blackhole.ts\n    |   |   |-- helper.ts\n    |   |   |-- login.ts\n    |   |   |-- user.ts\n    |   |-- types\n    |       |-- index.ts\n    |-- test\n        |-- blackhole.test.ts\n        |-- login.test.ts\n        |-- user.test.ts\n```\n\nChangelog\n----\n[Link](./CHANGELOG.md)\n\nLicense\n----\n[MIT](./LICENSE)\n\n\nAuthor\n----\n[Peter A. Tariche](https://github.com/ptariche)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fptariche%2Ftypescript-koa-mongoose-starter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fptariche%2Ftypescript-koa-mongoose-starter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fptariche%2Ftypescript-koa-mongoose-starter/lists"}