{"id":22934887,"url":"https://github.com/mavagio/mean-ts-auth","last_synced_at":"2025-08-12T18:31:09.635Z","repository":{"id":97341765,"uuid":"133935127","full_name":"mavagio/mean-ts-auth","owner":"mavagio","description":"MEAN stack boilerplate, TypeScript codebase, Passport.js with JWT authentication","archived":false,"fork":false,"pushed_at":"2020-05-25T09:45:17.000Z","size":2352,"stargazers_count":8,"open_issues_count":1,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-10-14T15:21:51.235Z","etag":null,"topics":["angular6","authentication","express","mean-stack","mongodb","mongoose","nodejs","passport-local","passportjs","typescript"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mavagio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2018-05-18T09:43:50.000Z","updated_at":"2021-12-26T19:03:39.000Z","dependencies_parsed_at":null,"dependency_job_id":"8ed9b6be-c092-4b86-8220-02c55935ac14","html_url":"https://github.com/mavagio/mean-ts-auth","commit_stats":null,"previous_names":["mavagio/mean-ts-auth"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mavagio%2Fmean-ts-auth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mavagio%2Fmean-ts-auth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mavagio%2Fmean-ts-auth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mavagio%2Fmean-ts-auth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mavagio","download_url":"https://codeload.github.com/mavagio/mean-ts-auth/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229699859,"owners_count":18109852,"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":["angular6","authentication","express","mean-stack","mongodb","mongoose","nodejs","passport-local","passportjs","typescript"],"created_at":"2024-12-14T11:45:40.614Z","updated_at":"2024-12-14T11:45:41.097Z","avatar_url":"https://github.com/mavagio.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"The following README provides detailed steps on how to run the code locally as well as how to deploy the application to Heroku.\n\nIf you are interested only in TypeScript API check out https://github.com/martinavagyan/node-typescript-api.\n\n\nIn the last section explanation on how to create new endpoints is provided.\n## How to run locally\n\nPrerequisites\n---------------\nMake sure to have the following installed on your machine:\n- mongoDB (make sure to have mongod running locally when running the code on a local machine)\n- Node \u003e 8.9 (!important)\n\nRun the code\n---------------\n- Install dependencies. From root directory run:\n```\nnpm run install:dependencies\n```\n- Create .env file in server folder.\n- Copy the following lines to .env file.\n```\nPORT=3000\nDEV_DB='mongodb://localhost/boilerplateDb'\nNODE_ENV='development'\nJWT_SECRET='change_this_example_secret'\n```\n- (Optional) Add the following to .env file if you want to run MongoDB with cloud provider (e.g. Mlab):\n```\nPROD_DB={{the URI provided by mongoDB could providers, e.g. Mlab}}\n```\n- Run the application by starting the client and server separately:\n```\ncd server; npm start\n```\n```\ncd client; npm start\n```\n\nThis will create the database locally. By running the server with the command:\n```\nnpm run start:cloud\n```\nThe server will run in production environment. In addition the server will try to connect to mongoDB form cloud provider.\n## Deploy to Heroku\n- Demo: https://mean-ts-auth.herokuapp.com\n- Create a Heroku account and create a new project.\n- Select the Deployment method with GitHub.\n- Find the repository and connect Heroku with the Github repository you would like to deploy.\n- Set up the enviroment variable in settings section in Heroku, for that you will need these variables:\n```bash\nJWT_SECRET # the secret string for Json Web Token\nPROD_DB # the remote mongo database (e.g. Mlab)\nTZ # time zone, e.g. can be Netherlands/Amsterdam\n```\n- After running deploy Heroku will build the application and deploy.\n- In addition you can select \"Enable Auto Deploy\" and select a branch from the repo, this will make sure that every time you commit to the branch Heroku will reinitiate deployment. \n## Technology stack\nMEAN Stack with TypeScript\n- MongoDB\n- Angular 6+\n- Express\n- Node \u003e 8.9\n- TypeScript\n- JavaScript\n\n## Creating a new endpoint\n- Define your endpoint route in `server/src/api/routes/apiRoutes.ts`, example:\n```TypeScript\napp.route('/api/test/').get(apiController.test_get);\n```\n- Add function to handle the endpoint in `server/src/api/controllers/apiController.ts`, example:\n```TypeScript\nexports.test_get = (req: any, res: any) =\u003e {\n    testCtrl.getAll(req, res);\n};\n```\n\n## Creating a new model\n- Add the new model to `server/src/api/models`, example:\n```TypeScript\nimport mongoose = require('mongoose');\nimport {Schema, Document} from 'mongoose';\n\nexport interface ITest {\n    name: string;\n    email: string;\n    type: number;\n}\n\nconst TestSchema: Schema = new Schema({\n    name: String,\n    email: String,\n    type: Number,\n});\n\nexport interface ITestModel extends ITest, Document {\n}\n\nconst TestModel = mongoose.model\u003cITestModel\u003e('Test', TestSchema);\n\nexport default TestModel;\n```\n- Add controller for your model to `server/src/api/controllers`,\n the controller has to inherit from `baseController`, example:\n```TypeScript\nimport Base from './baseController';\n\nexport default class TestClass\u003cT extends any\u003e extends Base\u003cT\u003e {\n    constructor(model: T) {\n        super(model);\n    }\n\n    public insert = (req: any, res: any) =\u003e {\n        const obj = new this.model(req.body);\n        obj.save((err: any, item: any) =\u003e {\n            if (err) {\n                return console.error(err);\n            }\n            res.status(200).json(item);\n        });\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmavagio%2Fmean-ts-auth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmavagio%2Fmean-ts-auth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmavagio%2Fmean-ts-auth/lists"}