{"id":15103398,"url":"https://github.com/leolanese/angular-nodejs-restapi","last_synced_at":"2026-01-19T03:33:39.986Z","repository":{"id":221705774,"uuid":"755054095","full_name":"leolanese/Angular-NodeJS-RestAPI","owner":"leolanese","description":"Angular + NodeJS REST Api - Full Stack Development Workflow","archived":false,"fork":false,"pushed_at":"2024-02-15T14:00:23.000Z","size":722,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-02T02:47:49.596Z","etag":null,"topics":["angular2","expressjs","nodejs","rest-api","standalone-components","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/leolanese.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}},"created_at":"2024-02-09T10:47:19.000Z","updated_at":"2024-06-05T09:25:19.000Z","dependencies_parsed_at":"2024-02-15T15:01:30.631Z","dependency_job_id":null,"html_url":"https://github.com/leolanese/Angular-NodeJS-RestAPI","commit_stats":null,"previous_names":["leolanese/angular-nodejs-restapi"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leolanese%2FAngular-NodeJS-RestAPI","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leolanese%2FAngular-NodeJS-RestAPI/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leolanese%2FAngular-NodeJS-RestAPI/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leolanese%2FAngular-NodeJS-RestAPI/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leolanese","download_url":"https://codeload.github.com/leolanese/Angular-NodeJS-RestAPI/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247332545,"owners_count":20921853,"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":["angular2","expressjs","nodejs","rest-api","standalone-components","typescript"],"created_at":"2024-09-25T19:23:55.735Z","updated_at":"2026-01-19T03:33:39.980Z","avatar_url":"https://github.com/leolanese.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Angular (17+) + NodeJS Users Rest Api. Full-Stack Development Workflow\n\n## Goal\n\nShow the use of Angular services to consume local and remote end-points, provided localy by `NodeJS` \u0026 `ExpressJS and remotly using `JsonPlaceHolder` Services. We will be using Angular 17+ with stand-alone component and services.\n\n---\n\n## Fetching Users from my NodeJS (and ExpressJS) Rest API\n\n```js\n// Front-End\n🅰️ Creating an Angular app + Angular Material\n - Initialise GIT repo from GITHUB\n - Create APP:\n    - ng new users-rest-api --style=scss\n    - code .\n    - cd /user-rest-api/npm start\n🚉 Adding Angular Material UI\n    - ng add @angular/material\n🚙 Adding the HttpClient\n    - mkdir services\n    - cd src/app/services\n    - ng g s API-user\n    - mkdir models\n    - cd src/app/services\n    - ng g i users\n    - using HTTP Client\n🛴 Defining service \u0026 interface\n    - user Interface (based on public API Service `https://jsonplaceholder.typicode.com/users`)\n👥 Fetching \u0026 Displaying users\n```\n\n```js\n// Back-end\n🧨 Endpoint Customisation\n    - Moving out from `jsonplaceholder` to local NodeJS Rest API\n    - mkdir rest-api-nodejs\n    - cd rest-api-nodejs\n✨ initialising NodeJS with ExpressJS \n    - npm init -y\n    - npm i express\n    - npm i morgan\n    - npm i cors\n    - notepad server.js (add content)\n    - node --loader ts-node/esm server.mjs\n    - Adjust the `package.json` from \"type\": \"module\" to use imports\n    - Test API end-point: http://localhost:3000/users\n🎇 Adding Image Source for Users\n    - Using RoboHash for random images (https://robohash.org/${user.id}.png?set=set1\u0026size=45x4)\n    - Test App: http://localhost:4200/\n```\n\n## Demo\n\n![Local users API :3000 (Node served)](https://github.com/leolanese/Angular-users-API/blob/main/users-rest-api/src/app/img/localRestFulAPI.jpg)\n\n\n![Angular View users API :4200 (Node served)](https://github.com/leolanese/Angular-users-API/blob/main/users-rest-api/src/app/img/demoFinal.jpg)\n\n---\n\n## Local mock users locally to be served\n\n```js\n// server.mjs\nimport express from 'express';\nimport cors from 'cors';\n\nconst app = express();\nconst PORT = 3000;\n\nconst users = [\n  {\n    \"id\": 1,\n    \"name\": \"Leanne Graham\",\n    \"username\": \"Bret\",\n    \"email\": \"Sincere@april.biz\",\n    \"address\": {\n      \"street\": \"Kulas Light\",\n      \"suite\": \"Apt. 556\",\n      \"city\": \"Gwenborough\",\n      \"zipcode\": \"92998-3874\",\n      \"geo\": {\n        \"lat\": \"-37.3159\",\n        \"lng\": \"81.1496\"\n      }\n    },\n    \"phone\": \"1-770-736-8031 x56442\",\n    \"website\": \"hildegard.org\",\n    \"company\": {\n      \"name\": \"Romaguera-Crona\",\n      \"catchPhrase\": \"Multi-layered client-server neural-net\",\n      \"bs\": \"harness real-time e-markets\"\n    }\n  },\n  {\n    \"id\": 2,\n    \"name\": \"Ervin Howell\",\n    \"username\": \"Antonette\",\n    \"email\": \"Shanna@melissa.tv\",\n    \"address\": {\n      \"street\": \"Victor Plains\",\n      \"suite\": \"Suite 879\",\n      \"city\": \"Wisokyburgh\",\n      \"zipcode\": \"90566-7771\",\n      \"geo\": {\n        \"lat\": \"-43.9509\",\n        \"lng\": \"-34.4618\"\n      }\n    },\n    \"phone\": \"010-692-6593 x09125\",\n    \"website\": \"anastasia.net\",\n    \"company\": {\n      \"name\": \"Deckow-Crist\",\n      \"catchPhrase\": \"Proactive didactic contingency\",\n      \"bs\": \"synergize scalable supply-chains\"\n    }\n  },\n  {\n    \"id\": 3,\n    \"name\": \"Clementine Bauch\",\n    \"username\": \"Samantha\",\n    \"email\": \"Nathan@yesenia.net\",\n    \"address\": {\n      \"street\": \"Douglas Extension\",\n      \"suite\": \"Suite 847\",\n      \"city\": \"McKenziehaven\",\n      \"zipcode\": \"59590-4157\",\n      \"geo\": {\n        \"lat\": \"-68.6102\",\n        \"lng\": \"-47.0653\"\n      }\n    },\n    \"phone\": \"1-463-123-4447\",\n    \"website\": \"ramiro.info\",\n    \"company\": {\n      \"name\": \"Romaguera-Jacobson\",\n      \"catchPhrase\": \"Face to face bifurcated interface\",\n      \"bs\": \"e-enable strategic applications\"\n    }\n  },\n  {\n    \"id\": 4,\n    \"name\": \"Patricia Lebsack\",\n    \"username\": \"Karianne\",\n    \"email\": \"Julianne.OConner@kory.org\",\n    \"address\": {\n      \"street\": \"Hoeger Mall\",\n      \"suite\": \"Apt. 692\",\n      \"city\": \"South Elvis\",\n      \"zipcode\": \"53919-4257\",\n      \"geo\": {\n        \"lat\": \"29.4572\",\n        \"lng\": \"-164.2990\"\n      }\n    },\n    \"phone\": \"493-170-9623 x156\",\n    \"website\": \"kale.biz\",\n    \"company\": {\n      \"name\": \"Robel-Corkery\",\n      \"catchPhrase\": \"Multi-tiered zero tolerance productivity\",\n      \"bs\": \"transition cutting-edge web services\"\n    }\n  },\n  {\n    \"id\": 5,\n    \"name\": \"Chelsey Dietrich\",\n    \"username\": \"Kamren\",\n    \"email\": \"Lucio_Hettinger@annie.ca\",\n    \"address\": {\n      \"street\": \"Skiles Walks\",\n      \"suite\": \"Suite 351\",\n      \"city\": \"Roscoeview\",\n      \"zipcode\": \"33263\",\n      \"geo\": {\n        \"lat\": \"-31.8129\",\n        \"lng\": \"62.5342\"\n      }\n    },\n    \"phone\": \"(254)954-1289\",\n    \"website\": \"demarco.info\",\n    \"company\": {\n      \"name\": \"Keebler LLC\",\n      \"catchPhrase\": \"User-centric fault-tolerant solution\",\n      \"bs\": \"revolutionize end-to-end systems\"\n    }\n  }\n];\n\napp.use(cors()); // Enable CORS for all routes\n\n// Checking if the application is in development mode\n// If it is, morgan middleware is added to the express application to log HTTP requests\nif(process.env.MODE === 'development'){\n  app.use(morgan('dev'))  \n}\n\napp.use(express.json());\n\napp.get('/users', (req, res) =\u003e {\n  res.json(users);\n});\n\n// Starting the express server and listening for connections on the specified port.\napp.listen(PORT, (err) =\u003e  \n    (err) ? console.error(`Failed to start server: ${err}`) :  console.log(`Server running on: ${PORT}`)\n);\n```\n\n---\n\nThis project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 17.0.9.\n\n## Development server\n\nRun `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The application will automatically reload if you change any of the source files.\n\n## Code scaffolding\n\nRun `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`.\n\n## Build\n\nRun `ng build` to build the project. The build artifacts will be stored in the `dist/` directory.\n\n## Running unit tests\n\nRun `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).\n\n\n---\n### :100: \u003ci\u003eThanks!\u003c/i\u003e\n#### Now, don't be an stranger. Let's stay in touch!\n\n\u003ca href=\"https://github.com/leolanese\" target=\"_blank\" rel=\"noopener noreferrer\"\u003e\n  \u003cimg src=\"https://scastiel.dev/api/image/leolanese?dark\u0026removeLink\" alt=\"leolanese’s GitHub image\" width=\"600\" height=\"314\" /\u003e\n\u003c/a\u003e\n\n##### :radio_button: Linkedin: \u003ca href=\"https://www.linkedin.com/in/leolanese/\" target=\"_blank\"\u003eLeoLanese\u003c/a\u003e\n##### :radio_button: Twitter: \u003ca href=\"https://twitter.com/LeoLanese\" target=\"_blank\"\u003e@LeoLanese\u003c/a\u003e\n##### :radio_button: Portfolio: \u003ca href=\"https://www.leolanese.com\" target=\"_blank\"\u003ewww.leolanese.com\u003c/a\u003e\n##### :radio_button: DEV.to: \u003ca href=\"https://www.dev.to/leolanese\" target=\"_blank\"\u003edev.to/leolanese\u003c/a\u003e\n##### :radio_button: Blog: \u003ca href=\"https://www.leolanese.com/blog\" target=\"_blank\"\u003eleolanese.com/blog\u003c/a\u003e\n##### :radio_button: Questions / Suggestion / Recommendation: developer@leolanese.com\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleolanese%2Fangular-nodejs-restapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleolanese%2Fangular-nodejs-restapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleolanese%2Fangular-nodejs-restapi/lists"}