{"id":20018648,"url":"https://github.com/munkkeli/node-typescript-boilerplate","last_synced_at":"2026-04-13T03:02:12.774Z","repository":{"id":42696428,"uuid":"240057186","full_name":"Munkkeli/node-typescript-boilerplate","owner":"Munkkeli","description":"A boilerplate to get personal TypeScript Node projects up and running","archived":false,"fork":false,"pushed_at":"2023-03-05T14:30:17.000Z","size":454,"stargazers_count":2,"open_issues_count":6,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-27T05:13:56.282Z","etag":null,"topics":["express","node","nodemon","postgresql","prettier","typescript"],"latest_commit_sha":null,"homepage":"https://tuomas.id/","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/Munkkeli.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":"2020-02-12T16:13:47.000Z","updated_at":"2021-04-02T11:30:42.000Z","dependencies_parsed_at":"2024-11-13T08:24:09.527Z","dependency_job_id":"8a926086-c76c-4d06-b47d-d69490a5deca","html_url":"https://github.com/Munkkeli/node-typescript-boilerplate","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Munkkeli%2Fnode-typescript-boilerplate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Munkkeli%2Fnode-typescript-boilerplate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Munkkeli%2Fnode-typescript-boilerplate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Munkkeli%2Fnode-typescript-boilerplate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Munkkeli","download_url":"https://codeload.github.com/Munkkeli/node-typescript-boilerplate/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241451718,"owners_count":19964909,"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":["express","node","nodemon","postgresql","prettier","typescript"],"created_at":"2024-11-13T08:23:39.031Z","updated_at":"2026-04-13T03:02:07.724Z","avatar_url":"https://github.com/Munkkeli.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Boilerplate\r\n\r\n### Node, TypeScript, PostgreSQL, Express\r\n\r\nCreated by [https://tuomas.id/](https://tuomas.id/)\r\n\r\nThe goal of this boilerplate is to be a robust and feature rich [Express](https://expressjs.com/) API backend that can easily be developed on top of. Everything custom is included in the template files and can easily be inspected, modified and removed if necessary.\r\n\r\n### Install\r\n\r\n```bash\r\nnpm install\r\n```\r\n\r\n### Configure\r\n\r\n```bash\r\n# Create the .env file and configure\r\ncp .env.example .env\r\n```\r\n\r\n### Start\r\n\r\n```bash\r\n# To run without auto-restart\r\nnpm start\r\n\r\n# To run with auto-restart\r\nnpm run watch\r\n```\r\n\r\n## Conventions used\r\n\r\n### [Hashids](https://hashids.org/)\r\n\r\nWhen IDs are sent to the client, they should be obfuscated for improved security. This boilerplate uses Hashids to accomplish this.\r\n\r\n### SQL transactions\r\n\r\nSQL transactions are an incredibly powerful feature that way too many developers never end up taking advantage of.\r\nThis boilerplate implements a wrapper around [express](https://expressjs.com/) request handlers that takes care of async errors, DB transactions and return values.\r\nIf something goes wrong while calling an endpoint, the transaction will be automatically rolled back, and everything is like the request never happened.\r\n\r\n```js\r\nconst genericRouter = Router();\r\n\r\ngenericRouter.get(\r\n  '/generic/:id',\r\n  Request(async (trx, req, res) =\u003e {\r\n    const { id } = req.body;\r\n\r\n    // \u003cMultiple SQL queries and other endpoint logic\u003e\r\n\r\n    // All SQL queries done prior to this will be automatically rolled back\r\n    // Express responds with 500 status code\r\n    throw new Error('Oops');\r\n  })\r\n);\r\n```\r\n\r\nTo have a closer look at how this works, please see the `src/middleware.ts`\r\n\r\n### SQL template literals\r\n\r\nSQL queries should be simple and easy to write, but still secure agains injection attacks. ES6 template literals are a nice way to accomplish just that.\r\nThis boilerplate uses a custom wrapper around the [node-postgres](https://node-postgres.com/) PoolClient, that allows for template literal queries that automatically escape added parameters.\r\n\r\n```js\r\nawait trx.sql`\r\n  SELECT ${trx.select(columns)}\r\n  FROM \"Table\"\r\n  WHERE _id = ${_id}\r\n`;\r\n```\r\n\r\nTo see everything this client has to offer, please see the `src/lib/trx.ts` file.\r\n\r\n---\r\n\r\nWrite your own stuff here ✏️\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmunkkeli%2Fnode-typescript-boilerplate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmunkkeli%2Fnode-typescript-boilerplate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmunkkeli%2Fnode-typescript-boilerplate/lists"}