{"id":15071206,"url":"https://github.com/twknab/mean_template","last_synced_at":"2026-01-03T11:35:23.732Z","repository":{"id":128421415,"uuid":"81668489","full_name":"twknab/mean_template","owner":"twknab","description":"A basic MEAN Project Template (Ang 1.x) for the beginnings of a CRUD application.","archived":false,"fork":false,"pushed_at":"2017-10-10T00:59:33.000Z","size":2735,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-22T22:41:20.718Z","etag":null,"topics":["angular1","crud-application","mean-stack"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/twknab.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":"2017-02-11T17:18:24.000Z","updated_at":"2018-11-16T16:54:12.000Z","dependencies_parsed_at":null,"dependency_job_id":"fbf25fd3-1f51-44b2-8334-147fbacef8ec","html_url":"https://github.com/twknab/mean_template","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/twknab%2Fmean_template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twknab%2Fmean_template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twknab%2Fmean_template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twknab%2Fmean_template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/twknab","download_url":"https://codeload.github.com/twknab/mean_template/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243857889,"owners_count":20359251,"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":["angular1","crud-application","mean-stack"],"created_at":"2024-09-25T02:36:25.991Z","updated_at":"2026-01-03T11:35:23.706Z","avatar_url":"https://github.com/twknab.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# M E A N   |   T E M P L A T E   |   A n g 1 . x\n\nNotes: This file is a modularized MEAN project with a single `User` model schema with\nView partials for all CRUD operations.\n\n+ `/server` and `/client` folders have been created\n+ `angular` and `angular-route` are installed\n+ `mongoose`, `express`, `bodyParser` are installed\n+ custom validations in the `User` model has been created\n\n## Overview:\nBe sure to customize this project for your needs, and is merely purposed to be a\nrubric from which to build a fully functioning MEAN application without having to\ndo a lot of the more tedious initial tasks, in getting the project setup.\n\nFrom here, you could either delete the controllers, customize them, add on to them,\nor do anything you wish. But the modularization is already to go, as well as\nthe basic MEAN dependencies. Feel free to remove or add new ones, depending upon\nyour project needs.\n\nHow to customize this template is outlined below, along with a log of technical\nissues that I experienced during development/running additions.\n\n## How to Customize:\n\n1. Read this file.\n\n2. Clone this project.\n\n3. Rename your project folder (ie, the folder containing this file).\n\n4. Update the project's destination repo to your own:\n\n\t+ `git remote -v` // shows your repo's remote connections\n\t+ `git remote remove origin` // removes connection to my repo (origin)\n\t+ `git remote add origin {{your-new-git-project-url}}` // ie, https://github.com.../myUsername/myProject.git\n\n5. Install `node` and `bower` dependencies:\n\n\t+ `npm install`\n\t\t+ `express`, `body-parser`, and `mongoose` have been setup.\n\t\t+ you can add any additional dependencies (ie, `bcrypt`, `express-session` if you want via `npm install {{dependency}}`).\n\t+ `bower install`\n\t\t+ `angular` and `angular-route` have been setup.\n\n6. Update `package.json` to reflect your New Project name and your New Repository:\n\n \t+ Open `/package.json`\n\t+ Change the `name` field to your project name.\n\t+ Change the `Repository.url` to your github project  repo.\n\n7. Update database name to a name fitting for your project:\n\n \t+ Open `/server/config/db.js`\n\t+ Rename `dbName` variable to your desired database name used for MongoDB.\n\n8. Rename any mongoose models (`/server/models`) to fit your initial DB design.\n\n\t+ Only one Mongoose model template ('Users')  has been created.\n\n9. Rename your Angular Controller (`/client/controllers`):\n\n\t+ `$location` and `$routeParams` have been setup by default:\n\t**DELETE** if not needed else you will have loaded Angular services into\n\tyour project which are never called.\n\t+ Two controllers have been setup (`user-controller` and\n\t`user-edit-controller`), along with ability to load error objects.\n\t+ The first controller creates, reads all and deletes. The\n\tsecond controller edits and reads one. Full CRUD setup ready to go.\n\n10. Rename your  Angular Factory (`/client/factories`) to reflect your design.\n\n\t+ Only one Angular Factory has been created: This handles both the\n\t`user-controller` and the `user-edit-controller`.\n\t+ `$http` service has been loaded for you, **DELETE** if needed.\n\n11. Update your Angular Routes (`/client/config`) and your initial Views file:\n\n\t+ `/client/index.html` is your outer frame,\n\t+ `/client/html/index.html` is your first partial.\n\t+ `/client/html/edit.html` is the partial loaded for editing.\n\n12. Make sure you update your Angular Config file (`client/config/app.js`)\n\tto customize your Angular Module and to add or remove any additional Angular\n\tservices you may need.\n\t+ `ngRoute` has been setup by default.\n\n13. Check your server routes (`/server/config/routes.js`):\n\n\t+ By default a create method is setup for your default mongoose model.\n\t+ **BE SURE** to update both the mongoose model variable (`User` by default),\n\tand to update your method to reflect your appropriate mongoose query\n\tneeds. Only one method has been setup.\n\t+ Restful routing has been setup, along with one route which contains\n\ta route parameter (ie, `/myroute/:id`)\n\n14. Rename your server controllers:\n\n\t+ Only one has been setup to handle all CRUD operations for `User`: `/server/controllers/user-controller.js`\n\n15. Update your primary index page title and content (`/client/index.html`):\n\n\t+ `angular`, `angular-route` have been loaded by default.\n\t+ Your angular app, controllers and factories have been loaded by\n\tdefault: **BE SURE** to update these filenames to the changes you made\n\tabove.\n\n16. Update `/server/config/app.js`\n\n\t+ If using session, setup, else **DELETE** unneeded commenting (Session\n\tis already setup, but not `npm` installed, and uncommenting the info\n\twill invoke it).\n\t+ bodyParser URL Encoded is setup also for uncommenting and usage.\n\n17. Test your file by launching it!\n\n\t+ `npm start` from the root project directory.\n\t+ By default, the port is setup to run on 8000.\n\t+ Open your browser: http://localhost:8000 should load!\n\n### New Features Log:\n\n+ **02/22/17**: Cleaned up `Readme.md` Added `.gitignore` to ignore `node_modules`\nand `bower_components` folders, removed plural from `UsersController` variable\nname to `UserController` in server-side Controller.\n\n### Development Issues Log:\n\n1. Custom RegExp Case Insensitive Query Not Catching Username as It Should:\n\n\t+ If my `username` was `timknab`, `timkna` would come back as TRUE, while\n\t`timknabber` would come back as FALSE when regex testing. Thus, when\n\ttrying to update the username field to `timkna` (from previously, `timknab`)\n\twas throwing the `already exists` custom error I created, even though this\n\tuser didn't exist. This bug was only found now during the edit build out\n\tfunctionality of the CRUD operations.\n\n\t### Solution:\n\n\t+ I made an error by using the wrong RegExp pattern, when doing my `pre`\n\tvalidations for a case insensitive mongoose query (designed to see if\n\tan existing user, no matter the case, exists).\n\t+ Because my previous Query was:\n\n\t`User.findOne({username: { $regex : new RegExp(username, \"i\")}})`\n\n\t+ This RegExp pattern I was using was incorrect. The `RegExp` obj would\n\tbe built similar to `\\timknab\\i`, where what we needed, for exact\n\tstring match, is, `\\^timknab$\\`. So the regex object you were making\n\tand testing was wrong.\n\t+ Here is the correct pattern, which searches for **EXACT** word match\n\tvia `^` and `$`:\n\n\t`User.findOne({username: { $regex : new RegExp(\"^\" + username + \"$\", \"i\")}})`\n\n\t+ Adding the carrot and dollar sign symbols lock the pattern to match\n\tfor an exact string. This way, `timkna` won't match for `timknab`,\n\tlike in the previous scenario. Only `timknab` will match for `timknab`,\n\texactly.\n\n2. Update operation (`findOneAndUpdate()` via Mongoose) was not running\nValidations:\n\n\t+ All validations, including post, pre and built in hooks were not running.\n\n\t### Solution:\n\n\t+ Using `findByIdAndUpdate` bypasses validations and `pre` and `post`\n\tmiddleware hooks. You have to nest your queries and invoke `.save()`\n\tin order for the validations to again run.\n\t+ To Do This: First lookup the user, then use `.save()`: the `save()`\n\tfunction by default runs the validations, including `pre` and `post`\n\tmongoose middleware hooks.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftwknab%2Fmean_template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftwknab%2Fmean_template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftwknab%2Fmean_template/lists"}