{"id":15353569,"url":"https://github.com/murderlon/be-assessment-2","last_synced_at":"2026-02-27T03:33:39.223Z","repository":{"id":118988330,"uuid":"127624938","full_name":"Murderlon/be-assessment-2","owner":"Murderlon","description":"🎓 Production ready express setup - CMDA Backend","archived":false,"fork":false,"pushed_at":"2018-04-13T11:36:53.000Z","size":18176,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-27T19:26:10.527Z","etag":null,"topics":["assignment","backend","cmda","express","production-ready"],"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/Murderlon.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":"2018-04-01T11:56:28.000Z","updated_at":"2023-03-04T03:22:02.000Z","dependencies_parsed_at":"2023-12-26T15:06:50.590Z","dependency_job_id":null,"html_url":"https://github.com/Murderlon/be-assessment-2","commit_stats":{"total_commits":53,"total_committers":1,"mean_commits":53.0,"dds":0.0,"last_synced_commit":"c240e2defaab6f9fedc0577f665aec7435425bfc"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Murderlon/be-assessment-2","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Murderlon%2Fbe-assessment-2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Murderlon%2Fbe-assessment-2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Murderlon%2Fbe-assessment-2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Murderlon%2Fbe-assessment-2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Murderlon","download_url":"https://codeload.github.com/Murderlon/be-assessment-2/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Murderlon%2Fbe-assessment-2/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29883768,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-26T23:51:21.483Z","status":"online","status_checked_at":"2026-02-27T02:00:06.759Z","response_time":57,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["assignment","backend","cmda","express","production-ready"],"created_at":"2024-10-01T12:14:27.762Z","updated_at":"2026-02-27T03:33:39.209Z","avatar_url":"https://github.com/Murderlon.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# be-assessment-2\n\n\u003e Production ready `express` setup.\n\n## Content\n\n* [🏗 Architecture](#-architecture)\n* [🔐 Security](#-security)\n* [🔁 Sessions](#-sessions)\n* [⬆️ Uploads](#-uploads)\n* [👩‍💻 Install](#-install)\n* [⚖️ Licence](#-licence)\n\n## 🏗 Architecture\n\nArchitecture is done as modular as possible, `server.js` only serves as a high-level overview as it passes further middleware setup to `lib/` and requests to distinguished routers in `routes/`.\n\n```\nbe-assessment-2/\n├─ lib/\n├─ models/\n├─ node_modules/\n├─ routes/\n├─ static/\n│  └─ img/\n│  └─ ...\n├─ view/\n│  └─ partials/\n│  └─ ...\n├─ .env\n├─ package.json\n├─ README.md\n├─ server.js\n└─ ...\n```\n\n## 🔐 Security\n\n### [`Passport`](http://www.passportjs.org/)\n\n\u003e Simple, unobtrusive authentication\n\n### [`Helmet`](https://helmetjs.github.io/)\n\n\u003e Secure Express apps by setting various HTTP headers.\n\n## 🔁 Sessions\n\nUser can stay logged in through `express-session`. Additionally, when the server restarts the sessions stay in place because they are saved in `MongoDB` with `connect-mongo`, as can be seen by the `store` property below.\n\n```js\n// ...\n.use(\n  session({\n    secret: process.env.SESSION_SECRET,\n    resave: false,\n    saveUninitialized: false,\n    store: new MongoStore({ mongooseConnection: mongoose.connection })\n  })\n)\n// ...\n```\n\nThe `process.env.SESSION_SECRET` is a 64 character crypto string.\n\n## ⬆️ Uploads\n\nFile uploads are done with `multer` with custom settings to generate unique file names with `shortid`. How unique are pseudo-random generators you may ask? According to [this](https://stackoverflow.com/questions/29605672/how-to-generate-short-unique-names-for-uploaded-files-in-nodejs#29608123) answer on Stackoverflow we're pretty safe:\n\n\u003e While shortid's are not guaranteed to be unique, the likelihood of a collision is extremely small. Unless you generate billions of entries per year, you could safely assume that a collision will never happen.\n\nCustom settings for `multer`:\n\n```js\nconst storage = multer.diskStorage({\n  destination: (req, file, cb) =\u003e cb(null, 'static/img'),\n  filename: (req, { originalname }, cb) =\u003e\n    cb(null, shortid.generate() + path.extname(originalname))\n})\n```\n\n## ‍💻 Install\n\n1.  **Get a MongoDB database, either locally or online.**\n\n* Local recommendation: [Kitematic](https://kitematic.com/).\n* Online recommendation: [MLab](https://mlab.com/)\n\n2.  **Get this repository.**\n\n```\n$ git clone https://github.com/Murderlon/be-assessment-2.git\n```\n\n3.  **Install dependencies.**\n\n```\n$ yarn\n```\n\nor\n\n```\n$ npm install\n```\n\n4.  **Create your `.env` file** (and fill in the empty variables).\n\n```bash\n$ echo 'DB_URL=\n  SESSION_SECRET=' \u003e .env\n```\n\n5.  **Run it.**\n\n```\nyarn start\n```\n\nor\n\n```\nnpm start\n```\n\nThat's it!\n\n## ⚖️ Licence\n\n[MIT](https://oss.ninja/mit/murderlon) © [Merlijn Vos](https://github.com/Murderlon).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmurderlon%2Fbe-assessment-2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmurderlon%2Fbe-assessment-2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmurderlon%2Fbe-assessment-2/lists"}