{"id":13496452,"url":"https://github.com/app-generator/api-server-nodejs","last_synced_at":"2025-04-06T16:15:27.326Z","repository":{"id":41417620,"uuid":"195116803","full_name":"app-generator/api-server-nodejs","owner":"app-generator","description":"Nodejs API Server - Express / SQLite / TypeORM | AppSeed","archived":false,"fork":false,"pushed_at":"2023-12-11T10:29:27.000Z","size":261,"stargazers_count":234,"open_issues_count":0,"forks_count":88,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-03-29T06:51:47.149Z","etag":null,"topics":["api-node","api-nodejs","appseed","appseed-sample","node-api","node-api-base","node-application","node-oauth","node-starter","node-starter-kit","node-template","nodejs","nodejs-api","nodejs-server","nodejs-starter-kit","nodejs-starter-template","typeorm"],"latest_commit_sha":null,"homepage":"https://appseed.us/boilerplate-code/nodejs-starter/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/app-generator.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","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":"2019-07-03T19:41:09.000Z","updated_at":"2025-03-09T23:19:28.000Z","dependencies_parsed_at":"2024-11-09T18:02:34.467Z","dependency_job_id":"5433ab4c-8a26-4632-b796-d8fbfba2a684","html_url":"https://github.com/app-generator/api-server-nodejs","commit_stats":null,"previous_names":[],"tags_count":16,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/app-generator%2Fapi-server-nodejs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/app-generator%2Fapi-server-nodejs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/app-generator%2Fapi-server-nodejs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/app-generator%2Fapi-server-nodejs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/app-generator","download_url":"https://codeload.github.com/app-generator/api-server-nodejs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247509238,"owners_count":20950232,"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-node","api-nodejs","appseed","appseed-sample","node-api","node-api-base","node-application","node-oauth","node-starter","node-starter-kit","node-template","nodejs","nodejs-api","nodejs-server","nodejs-starter-kit","nodejs-starter-template","typeorm"],"created_at":"2024-07-31T19:01:48.080Z","updated_at":"2025-04-06T16:15:27.295Z","avatar_url":"https://github.com/app-generator.png","language":"TypeScript","readme":"\n# [Nodejs API Server](https://appseed.us/product/soft-ui-dashboard/api-server-nodejs/react/)\n\n[Express/Nodejs Starter](https://appseed.us/product/soft-ui-dashboard/api-server-nodejs/react/) with `JWT Authentication`, OAuth (Github), and **SQLite** persistence - Provided by `AppSeed`. Authentication Flow uses `json web tokens` via Passport library - `passport-jwt` strategy.\n\n\u003e 👉 [Support](https://appseed.us/support/) via **Discord \u0026 Email** provided by `AppSeed`. \n\n\u003cbr /\u003e\n\n## Features\n\n- 🚀 `Full-stack ready` with [React Soft Dashboard](https://appseed.us/product/soft-ui-dashboard/api-server-nodejs/react/)\n- ✅ Simple, intuitive codebase - can be extended with ease.  \n- ✅ `TypeScript`, `Joy` for validation\n- ✅ **Stack**: NodeJS / Express / SQLite / TypeORM\n- ✅ Auth: Passport / `passport-jwt` strategy \n- 🆕 `OAuth` for **Github**\n  \n\u003cbr /\u003e\n\n\u003e Tested with:\n\n| NodeJS | NPM | YARN | \n| --- | --- | --- | \n| `v18.0.0`  | ✅ | ✅ |\n| `v16.10.0` | ✅ | ✅ | \n| `v14.15.0` | ✅ | ✅ | \n\n\u003cbr /\u003e\n\n![Nodejs API Server - Open-source Nodejs Starter provided by AppSeed.](https://user-images.githubusercontent.com/51070104/124414813-142aa180-dd5c-11eb-9279-6b082dadc51a.png)\n\n\u003cbr /\u003e\n\n## ✨ Requirements\n\n- [Node.js](https://nodejs.org/) \u003e= v16.13\n- [SQLite](https://www.sqlite.org/index.html)\n\n\u003cbr /\u003e\n\n## ✨ How to use the code\n\n\u003e 👉 **Step 1** - Clone the project\n\n```bash\n$ git clone https://github.com/app-generator/api-server-nodejs.git\n$ cd api-server-nodejs\n```\n\n\u003cbr /\u003e\n\n\u003e 👉 **Step 2** - Install dependencies via `Yarn`\n\n```bash\n$ npm i\n// OR \n$ yarn\n```\n\n\u003cbr /\u003e\n\n\u003e 👉 **Step 3** - Run the SQLite migration via TypeORM\n\n```\n$ npm run typeorm migration:run\n// OR \n$ yarn typeorm migration:run\n```\n\n\u003cbr /\u003e\n\n\u003e 👉 **Step 4** - Edit the `.env` using the template `.env.sample`. \n\n```env\nPORT=5000                       # API PORT\nSQLITE_PATH=./database.db       # Path to the SQLite database file\nSECRET=\"Whatever-STRONG\"        # Secret for sensitive data hashing \n\n# Same as for React APP\nGITHUB_OAUTH_CLIENT_ID= ...     # Github OAuth secret \nGITHUB_OAUTH_CLIENT_SECRET= ... # Github OAuth secret\n```\n\n\u003cbr /\u003e\n\n\u003e 👉 **Step 5** - Start the API server (development mode)\n\n```bash\n$ npm run dev\n// OR\n$ yarn dev\n```\n\n\u003cbr /\u003e\n\n\u003e 👉 **Step 6** - Production Build (files generated in `build` directory)\n\n```bash\n$ yarn build\n```\n\n\u003cbr /\u003e\n\n\u003e 👉 **Step 7** - Start the API server for production (files served from `build/index.js`)\n\n```bash\n$ yarn start\n```\n\nThe API server will start using the `PORT` specified in `.env` file (default 5000).\n\n\u003cbr /\u003e\n\n## ✨ Codebase Structure\n\n```bash\n\u003c ROOT / src \u003e\n     | \n     |-- config/                              \n     |    |-- config.ts             # Configuration       \n     |    |-- passport.ts           # Define Passport Strategy             \n     | \n     |-- migration/\n     |    |-- some_migration.ts     # database migrations\n     |\n     |-- models/                              \n     |    |-- activeSession.ts      # Sessions Model (Typeorm)              \n     |    |-- user.ts               # User Model (Typeorm) \n     | \n     |-- routes/                              \n     |    |-- users.ts              # Define Users API Routes\n     | \n     | \n     |-- index.js                   # API Entry Point\n     |-- .env                       # Specify the ENV variables\n     |                        \n     |-- ************************************************************************\n```\n\n\u003cbr /\u003e\n\n## ✨ SQLite Path\n\nThe SQLite Path is set in `.env`, as `SQLITE_PATH`\n\n\u003cbr /\u003e\n\n## ✨ Database migration\n\n\u003e 👉 Generate migration:\n\n```bash\n$ yarn typeorm migration:generate -n your_migration_name\n```\n\n\u003e 👉 Run migration: \n\n```bash\n$ yarn typeorm migration:run\n```\n\n\u003cbr /\u003e\n\n## ✨ API\n\nFor a fast set up, use this POSTMAN file: [api_sample](https://github.com/app-generator/api-server-nodejs-pro/blob/master/media/api.postman_collection.json)\n\n\u003e 👉 **Register** - `api/users/register`\n\n```\nPOST api/users/register\nContent-Type: application/json\n\n{\n    \"username\":\"test\",\n    \"password\":\"pass\", \n    \"email\":\"test@appseed.us\"\n}\n```\n\n\u003cbr /\u003e\n\n\u003e 👉 **Login** - `api/users/login`\n\n```\nPOST /api/users/login\nContent-Type: application/json\n\n{\n    \"password\":\"pass\", \n    \"email\":\"test@appseed.us\"\n}\n```\n\n\u003cbr /\u003e\n\n\u003e 👉 **Logout** - `api/users/logout`\n\n```\nPOST api/users/logout\nContent-Type: application/json\nauthorization: JWT_TOKEN (returned by Login request)\n\n{\n    \"token\":\"JWT_TOKEN\"\n}\n```\n\n\u003cbr /\u003e\n\n## ✨ Update role for existing user\n\n\u003e 👉 Using npm: \n\n```$ npm run update-role [user_id] [role_id (optional)]```\n\n\u003cbr /\u003e\n\n\u003e 👉 Using yarn: \n\n```$ yarn update-role [user_id] [role_id (optional)]```\n\n- [user_id] is the id of existing user to update role for.\n- [role_id] is the id of role: 1 for admin \u0026 2 for user. If you don't provide any role_id it would update user to admin role.\n\n\u003cbr /\u003e\n\n## ✨ Run the Tests (`minimal suite`)\n\n```\n$ npm run test\n// OR\n$ yarn test\n```\n\n\u003cbr /\u003e\n\n## ✨ Credits\n\nThis software is provided by the core AppSeed team with an inspiration from other great NodeJS starters: \n\n- Initial verison - coded by [Teo Deleanu](https://www.linkedin.com/in/teodeleanu/)\n- [Hackathon Starter](https://github.com/sahat/hackathon-starter) - A truly amazing boilerplate for Node.js apps\n- [Node Server Boilerplate](https://github.com/hagopj13/node-express-boilerplate) - just another cool starter\n- [React NodeJS Argon](https://github.com/creativetimofficial/argon-dashboard-react-nodejs) - released by **Creative-Tim** and [ProjectData](https://projectdata.dev/)\n\n\u003cbr /\u003e\n\n---\n**[Node JS API Server](https://appseed.us/boilerplate-code/nodejs-starter/)** - provided by AppSeed [App Generator](https://appseed.us)\n","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapp-generator%2Fapi-server-nodejs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fapp-generator%2Fapi-server-nodejs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapp-generator%2Fapi-server-nodejs/lists"}