{"id":24815515,"url":"https://github.com/albinojunior/node-crudapi-ts","last_synced_at":"2025-10-13T18:31:48.427Z","repository":{"id":44143109,"uuid":"171939490","full_name":"albinojunior/node-crudapi-ts","owner":"albinojunior","description":"CRUD boilerplate for create Node Restful API's with Express Framework and Sequelize ORM written in Typescript.","archived":false,"fork":false,"pushed_at":"2022-12-22T11:07:57.000Z","size":338,"stargazers_count":44,"open_issues_count":10,"forks_count":16,"subscribers_count":3,"default_branch":"master","last_synced_at":"2023-10-20T16:20:55.220Z","etag":null,"topics":["api","api-rest","boilerplate","es6","es7","express","expressjs","node","nodejs","nosql","orm","restful-api","sequelize","sql","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/albinojunior.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}},"created_at":"2019-02-21T20:22:12.000Z","updated_at":"2023-07-29T13:12:58.000Z","dependencies_parsed_at":"2023-01-30T07:31:02.806Z","dependency_job_id":null,"html_url":"https://github.com/albinojunior/node-crudapi-ts","commit_stats":null,"previous_names":[],"tags_count":0,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/albinojunior%2Fnode-crudapi-ts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/albinojunior%2Fnode-crudapi-ts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/albinojunior%2Fnode-crudapi-ts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/albinojunior%2Fnode-crudapi-ts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/albinojunior","download_url":"https://codeload.github.com/albinojunior/node-crudapi-ts/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":236385781,"owners_count":19140689,"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":["api","api-rest","boilerplate","es6","es7","express","expressjs","node","nodejs","nosql","orm","restful-api","sequelize","sql","typescript"],"created_at":"2025-01-30T17:00:42.536Z","updated_at":"2025-10-13T18:31:43.135Z","avatar_url":"https://github.com/albinojunior.png","language":"TypeScript","readme":"\u003ch1 align=\"center\"\u003eNode CrudAPI Boilerplate | TypeScript\u003c/h1\u003e\r\n\u003cp align=\"center\"\u003e\u003ca href=\"http://nodejs.org\" target=\"blank\"\u003eNode\u003c/a\u003e boilerplate for create CRUDs and restful API's with \u003ca href=\"https://expressjs.com/\" target=\"blank\"\u003eExpress Framework\u003c/a\u003e and \u003ca href=\"https://docs.sequelizejs.com\" target=\"blank\"\u003eSequelize ORM\u003c/a\u003e written in \u003ca href=\"https://www.typescriptlang.org/\" target=\"blank\"\u003eTypescript\u003c/a\u003e.\u003c/p\u003e\r\n\u003cp align=\"center\"\u003e\r\n\u003c/p\u003e\r\n\r\n- [1.  Installing](#1-installing)\r\n  - [Install dependencies](#install-dependencies)\r\n  - [Installing pm2](#installing-pm2)\r\n  - [Environments](#environments)\r\n- [2. Database](#2-database)\r\n  - [Install database driver](#install-database-driver)\r\n  - [Database Config](#database-config)\r\n  - [Migrations and Seeders](#migrations-and-seeders)\r\n  - [Creating Migration](#creating-migration)\r\n  - [Running Migration](#running-migration)\r\n  - [Creating Seed](#creating-seed)\r\n  - [Running Seed](#running-seed)\r\n- [3.  Schedules](#3-schedules)\r\n  - [Installing](#installing)\r\n  - [Configuring](#configuring)\r\n- [4. Running](#4-running)\r\n- [5. Building](#5-building)\r\n  - [DEV](#dev)\r\n  - [PROD](#prod)\r\n- [6. Docs](#6-docs)\r\n\r\n## 1.  Installing\r\n\r\n#### Install dependencies\r\n\r\n```bash\r\n$ npm i\r\n```\r\n\r\n#### Installing pm2\r\n```bash\r\n$ npm i -g pm2\r\n```\r\n\r\n#### Environments\r\n\r\nCopy `.env.example` to `.env` and set environments\r\n\r\n## 2. Database\r\n#### Install database driver\r\n\r\n- **PostgresSQL**\r\n```bash\r\n$ npm install --save pg pg-hstore\r\n```\r\n\r\n- **MySQL**\r\n```bash\r\n$ npm install --save mysql2\r\n```\r\n\r\n- **MariaDB**\r\n```bash\r\n$ npm install --save mariadb\r\n```\r\n\r\n- **SQLite**\r\n```bash\r\n$ npm install --save sqlite3\r\n```\r\n\r\n- **SQL Server**\r\n```bash\r\n$ npm install --save tedious\r\n```\r\n\r\n#### Database Config\r\nSetting config database connection on config file:  `config/database.js`\r\n***if you will not use migrations or seeds this config  can be created with \".ts\" extension**\r\n[more config details](http://docs.sequelizejs.com/manual/getting-started.html)\r\n\r\n#### Migrations and Seeders\r\n- For implements migrations or seeds install sequelize-cli module:\r\n\r\n```bash\r\n$ npm i -g sequelize-cli\r\n```\r\n\r\n- Create `database/seeders` and/or  `database/migrations` folder\r\n*OBS: You can create seeds or migrations folders individually*\r\n\r\n- Create a `.sequeilizerc` and paste follow code:\r\n\r\n```\r\nmodule.exports = {\r\n  \"config\": \"./config/database.js\", //database config file reference\r\n  \"seeders-path\": \"./database/seeders\", //remove if you don't use seeders\r\n  \"migrations-path\": \"./database/migrations\" //remove if you don't use migrations\r\n};\r\n```\r\n\r\n#### Creating Migration\r\n\r\n```bash\r\n$ sequelize migration:create --name MIGRATION_NAME\r\n```\r\n\r\n#### Running Migration\r\n\r\n```bash\r\n$ sequelize db:migrate\r\n```\r\n\r\n#### Creating Seed\r\n\r\n```bash\r\n$ sequelize seed:create --name SEED_NAME\r\n```\r\n\r\n#### Running Seed\r\n```bash\r\n$ sequelize db:seed:all\r\n```\r\n\r\n\r\n## 3.  Schedules\r\n#### Installing\r\n- For implements Schedules install node-schedule module:\r\n\r\n```bash\r\n$ npm i node-schedule --save\r\n```\r\n\r\n```bash\r\n$ npm i @types/node-schedule --save-dev\r\n```\r\n\r\n#### Configuring\r\n\r\n- Create `src/jobs` folder and view [example](https://github.com/albinojunior/nodeapi-typescript/blob/master/examples/job.example.ts) of job file.\r\n\r\n- Create `src/schedule.ts` file ande paste follow code or copy from [example](https://github.com/albinojunior/nodeapi-typescript/blob/master/examples/schedule.example.ts)\r\n\r\n```javascript\r\n/* src/schedule.ts */\r\nimport { resolve } from \"path\";\r\nimport { scheduleJob } from \"node-schedule\";\r\n\r\nimport * as fs from \"fs\";\r\nimport { Job } from \"./common/interfaces/job\";\r\n\r\nconst env = process.env.NODE_ENV || \"development\";\r\nconst prefix = env == \"development\" ? \"\" : \"build/\";\r\n\r\nexport default class Schedule {\r\n  public jobs: Job[] = [];\r\n\r\n  public constructor() {\r\n    this.getJobs();\r\n  }\r\n\r\n  public getJobs = (): void =\u003e {\r\n    const path = resolve(`${prefix}src/jobs`);\r\n    let files = fs.readdirSync(path);\r\n    this.jobs = files.map((file): Job =\u003e require(`./jobs/${file}`).default);\r\n  };\r\n\r\n  public startJobs = (): void =\u003e {\r\n    this.jobs.map(\r\n      (job: Job): void =\u003e {\r\n        if (job.enabled)\r\n          scheduleJob(job.date, async (): Promise\u003cvoid\u003e =\u003e await job.execute());\r\n      }\r\n    );\r\n  };\r\n}\r\n\r\n```\r\n- Import `src/schedule.ts` on app and call **startJobs()** method on *App* constructor\r\n\r\n\r\n##  4. Running\r\n\r\n```bash\r\n$ npm run dev\r\n```\r\n\r\n## 5. Building\r\n\r\n#### DEV\r\n\r\n```bash\r\n$ npm run build:dev\r\n```\r\n\r\n#### PROD\r\n\r\n```bash\r\n$ npm run build\r\n```\r\n\r\n\r\n## 6. Docs\r\n\r\n- [Sequelize](http://docs.sequelizejs.com/)\r\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falbinojunior%2Fnode-crudapi-ts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falbinojunior%2Fnode-crudapi-ts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falbinojunior%2Fnode-crudapi-ts/lists"}