{"id":20887578,"url":"https://github.com/thederickff/pairbnb","last_synced_at":"2026-04-26T01:32:57.313Z","repository":{"id":39409765,"uuid":"204205786","full_name":"thederickff/PairBnB","owner":"thederickff","description":"A place booking app, where people can offer their places and you can book other places, a little bit like AirBnB","archived":false,"fork":false,"pushed_at":"2023-01-23T23:59:32.000Z","size":3467,"stargazers_count":3,"open_issues_count":27,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-19T11:17:39.420Z","etag":null,"topics":["airbnb","android","angular8","capacitor","ionic4"],"latest_commit_sha":null,"homepage":null,"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/thederickff.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":"2019-08-24T19:55:34.000Z","updated_at":"2024-09-24T15:28:34.000Z","dependencies_parsed_at":"2023-02-06T18:01:42.111Z","dependency_job_id":null,"html_url":"https://github.com/thederickff/PairBnB","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/thederickff%2FPairBnB","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thederickff%2FPairBnB/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thederickff%2FPairBnB/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thederickff%2FPairBnB/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thederickff","download_url":"https://codeload.github.com/thederickff/PairBnB/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243268612,"owners_count":20263897,"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":["airbnb","android","angular8","capacitor","ionic4"],"created_at":"2024-11-18T08:21:08.872Z","updated_at":"2025-12-29T01:32:13.882Z","avatar_url":"https://github.com/thederickff.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PairBnB\n\nA place booking app, where people can offer their places and you can book other places, a little bit like AirBnB\n\n## Important\n\nPaste this code below as a new file \u003ccode\u003esrc/environments/environment.ts\u003c/code\u003e\n\n```typescript\n// This file can be replaced during build by using the `fileReplacements` array.\n// `ng build --prod` replaces `environment.ts` with `environment.prod.ts`.\n// The list of file replacements can be found in `angular.json`.\n\nexport const environment = {\n  production: false,\n  // I am using firebase's realtime database url, you can use any other\n  serverBaseUrl: \"\u003cPLACE YOUR BACKEND URL HERE\u003e\",\n  googleMapsApiKey: \"\u003cPLACE YOUR GOOGLE MAPS API KEY HERE\u003e\",\n  firebaseApiKey: \"\u003cPLACE YOUR FIREBASE API KEY HERE\u003e\"\n};\n\n/*\n * For easier debugging in development mode, you can import the following file\n * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`.\n *\n * This import should be commented out in production mode because it will have a negative impact\n * on performance if an error is thrown.\n */\n// import 'zone.js/dist/zone-error';  // Included with Angular CLI.\n```\n\n### Install globally firebase-tools with\n\n\u003ccode\u003enpm install -g firebase-tools\u003c/code\u003e\nLogin\n\u003ccode\u003efirebase login\u003c/code\u003e\nAnd init\n\u003ccode\u003efirebase init\u003c/code\u003e\nSelect the \u003ccode\u003efunctions\u003c/code\u003e option and select a project\nThe folder \u003ccode\u003efunctions\u003c/code\u003e will be created.\nThen paste this code into \u003ccode\u003efunctions/index.js\u003c/code\u003e (this is of course, the Firebase Cloud Functions which will be by the app).\n\n```javascript\nconst functions = require(\"firebase-functions\");\nconst cors = require(\"cors\")({ origin: true });\nconst Busboy = require(\"busboy\");\nconst os = require(\"os\");\nconst path = require(\"path\");\nconst fs = require(\"fs\");\nconst uuid = require(\"uuid/v4\");\n\nconst { Storage } = require(\"@google-cloud/storage\");\n\nconst storage = new Storage({\n  projectId: \"YOUR_FIREBASE_PROJECT_ID\"\n});\n\nexports.storeImage = functions.https.onRequest((req, res) =\u003e {\n  return cors(req, res, () =\u003e {\n    if (req.method !== \"POST\") {\n      return res.status(500).json({ message: \"Not allowed.\" });\n    }\n    const busboy = new Busboy({ headers: req.headers });\n    let uploadData;\n    let oldImagePath;\n\n    busboy.on(\"file\", (fieldname, file, filename, encoding, mimetype) =\u003e {\n      const filePath = path.join(os.tmpdir(), filename);\n      uploadData = { filePath: filePath, type: mimetype, name: filename };\n      file.pipe(fs.createWriteStream(filePath));\n    });\n\n    busboy.on(\"field\", (fieldname, value) =\u003e {\n      oldImagePath = decodeURIComponent(value);\n    });\n\n    busboy.on(\"finish\", () =\u003e {\n      const id = uuid();\n      let imagePath = \"images/\" + id + \"-\" + uploadData.name;\n      if (oldImagePath) {\n        imagePath = oldImagePath;\n      }\n\n      console.log(uploadData.type);\n      return storage\n        .bucket(\"YOUR_FIREBASE_PROJECT_ID.appspot.com\")\n        .upload(uploadData.filePath, {\n          uploadType: \"media\",\n          destination: imagePath,\n          metadata: {\n            metadata: {\n              contentType: uploadData.type,\n              firebaseStorageDownloadTokens: id\n            }\n          }\n        })\n\n        .then(() =\u003e {\n          return res.status(201).json({\n            imageUrl:\n              \"https://firebasestorage.googleapis.com/v0/b/\" +\n              storage.bucket(\"YOUR_FIREBASE_PROJECT_ID.appspot.com\").name +\n              \"/o/\" +\n              encodeURIComponent(imagePath) +\n              \"?alt=media\u0026token=\" +\n              id,\n            imagePath: imagePath\n          });\n        })\n        .catch(error =\u003e {\n          console.log(error);\n          return res.status(401).json({ error: \"Unauthorized!\" });\n        });\n    });\n    return busboy.end(req.rawBody);\n  });\n});\n```\n\nAdd these four dependencies into \u003ccode\u003efunctions/package.json\u003c/code\u003e\n\n```json\n{\n  ...\n  \"dependencies\": {\n    ...\n    \"@google-cloud/storage\": \"^2.3.4\",\n    \"busboy\": \"^0.2.14\",\n    \"cors\": \"^2.8.4\",\n    \"uuid\": \"^3.2.1\"\n  },\n  ...\n}\n\n```\n\nThen finally use \u003ccode\u003enpm install\u003c/code\u003e inside the \u003ccode\u003efunctions/\u003c/code\u003e folder and use\n\u003ccode\u003efirebase deploy\u003c/code\u003e inside the project root folder.\n\nAfter that\ndefine the \u003ccode\u003euploadImageCloudFunctionUrl\u003c/code\u003e property on \u003ccode\u003esrc/environments/environment.ts\u003c/code\u003e:\n\n```javascript\nconst environment = {\n  ...,\n  uploadImageCloudFunctionUrl: '\u003cPLACE YOUR CLOUD FUNCTION URL HERE\u003e'\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthederickff%2Fpairbnb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthederickff%2Fpairbnb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthederickff%2Fpairbnb/lists"}