{"id":23414711,"url":"https://github.com/erosnol/fb-backend","last_synced_at":"2025-04-09T05:28:42.449Z","repository":{"id":48062361,"uuid":"516498131","full_name":"erosnol/fb-backend","owner":"erosnol","description":"fraxbook backend","archived":false,"fork":false,"pushed_at":"2022-07-22T07:37:08.000Z","size":40,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-15T00:14:57.099Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/erosnol.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}},"created_at":"2022-07-21T19:29:12.000Z","updated_at":"2022-07-21T19:54:38.000Z","dependencies_parsed_at":"2022-08-23T02:20:11.701Z","dependency_job_id":null,"html_url":"https://github.com/erosnol/fb-backend","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/erosnol%2Ffb-backend","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erosnol%2Ffb-backend/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erosnol%2Ffb-backend/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erosnol%2Ffb-backend/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/erosnol","download_url":"https://codeload.github.com/erosnol/fb-backend/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247985130,"owners_count":21028627,"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":[],"created_at":"2024-12-22T20:29:54.051Z","updated_at":"2025-04-09T05:28:42.425Z","avatar_url":"https://github.com/erosnol.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fb-backend\r\nfraxbook backend\r\n\r\nfull CRUD to create, login users, delete and update status/posts. \r\n\r\n### Installation\r\n\r\nMake a new folder on terminal \r\n\r\n```bash\r\nmkdir BlogAPI\r\n```\r\nClone repository\r\n\r\n```bash\r\ngit clone https://github.com/erosnol/Project-2API\r\n```\r\nOpen up Visual Studio Code\r\n```bash\r\ncode .\r\n```\r\n\r\n```bash\r\nnpm init -y \r\n```\r\nMake sure all dependencies are up-to-date and installed.\r\n\r\n```bash\r\n\"bcrypt\": \"^5.0.1\",\r\n    \"dotenv\": \"^16.0.1\",\r\n    \"ejs\": \"^3.1.8\",\r\n    \"express\": \"^4.18.1\",\r\n    \"express-validator\": \"^6.14.1\",\r\n    \"helmet\": \"^5.1.0\",\r\n    \"jsonwebtoken\": \"^8.5.1\",\r\n    \"mongoose\": \"^6.3.6\",\r\n    \"morgan\": \"^1.10.0\"\r\n```\r\n\r\nIf not, install dependencies using the following commands:\r\n```bash\r\nnpm i bcryt\r\nnpm i dotenv \r\nnpm i express ejs\r\nnpm i express-validator \r\nnpm i helmet\r\nnpm i jsonwentoken\r\nnpm i mongoose\r\nnpm i morgan\r\n```\r\n\r\nNames of ENV Variables \r\n```bash\r\nMONGO_DB\r\nMY_SECRET_KEY\r\n```\r\n\r\n### Running Locally \r\nCheck to see if you are in the /BlogAPI folder within the terminal.\r\n```bash\r\npwd \r\n```\r\n\r\ncd into /BlogAPI folder and run the server with nodemon \r\n```bash\r\ncd BlogAPI\r\nnodemon server.js\r\n```\r\nIf you do not have nodemon installed run this on the terminal \r\n```bash\r\nnpm i nodemon \r\n```\r\n### Routes \r\n```bash\r\n    Endpoints, Parameters, Schema\r\n```\r\n\r\n\r\n```bash \r\napp.use('/blog', blogRouter)\r\napp.use('/users', usersRouter)\r\napp.use('/auth', authRouter)\r\n```\r\n\r\n#### auth Router\r\n```bash\r\nAuth ('/auth') creates Users and Login \r\n - router.post('/') : Checks users email and password with '.isEmail' \u0026 '.notEmpty.' It also creates a TOKEN for user profile.\r\n```\r\n\r\n\r\n#### blog Router\r\n```bash\r\nrouter.get('/') - finds all blogs\r\n\r\nrouter.post('/') - creates a blog \r\n\r\nrouter.get('/') - find blog by id\r\n\r\nrouter.put('/') - updates blog by id\r\n\r\nrouter.delete('/') - deletes blog by id\r\n```\r\n\r\n#### user Router\r\n```bash\r\nrouter.post('/') - validates username, email, password with express validator. and use SALT and bcrypt to get a hashedpassword. With this, a payload exists and creates a TOKEN.\r\n```\r\n\r\n### Schemas\r\n#### user\r\n```bash\r\n `username: {\r\n        type: String,\r\n        required: true\r\n    },\r\n\r\n    email: {\r\n        type: String,\r\n        required: true,\r\n        unique: true\r\n    },\r\n\r\n    password: {\r\n        type: String,\r\n        required: true\r\n    },\r\n\r\n    age: {\r\n        type: Number\r\n    },\r\n\r\n    birthday: {\r\n        type: Date,\r\n        required: true\r\n    },\r\n\r\n    created_at: {\r\n        type: Date,\r\n        default: Date.now()\r\n    }`\r\n```\r\n\r\n#### blog\r\n```bash\r\n `private: {\r\n        type: Boolean,\r\n        required: true\r\n    },\r\n\r\n    blog_title: {\r\n        type: String,\r\n        required: true\r\n    },\r\n\r\n    blog_content: {\r\n        type: String,\r\n        required: true\r\n    },\r\n\r\n    created_at: {\r\n        type: Date,\r\n        default: Date.now()\r\n    },\r\n\r\n    created_by: {\r\n        type: String,\r\n        required: true\r\n    }`\r\n```\r\n\r\n## License\r\n[MIT](https://choosealicense.com/licenses/mit/)\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferosnol%2Ffb-backend","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ferosnol%2Ffb-backend","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferosnol%2Ffb-backend/lists"}