Source repository for https://unlimitedspace.azurewebsites.net/
- Weapons of choice... We are building a MEAN app!
- Frontend should be done in Angular.
- Database should be MongoDB.
- Server should be ExpressJS.
- Mongoose ODM should be used for object modelling with MongoDB.
- Maintain consistency in layout
- Use standard naming convention for variables and classes. e.g. PascalCase for classes, UPPERCASE for const and camelCase for viarables.
- Use line indentation for easy reading of code. Leave a space after closing classes or functions.
- Keep lines under 120 characters wide.
- Avoid trailing spaces. One or two lines to break up code for readability is preferred
- Documentation and comments
- All variables should be descriptive. Avoid using things like x.
- If the code isn't obvious on what it is doing, add inline comments to explain further.
- Add comments for code to be implemented at a later date.
- Incomplete code should not be commented out and pushed to master. Create a branch or stash this somewhere else.
- Git commits should be short one line subjects with no full stop. Thing in terms of: If applied, this commit will Add CCS styling for main page
-
Clone the repo
git clone https://github.com/divsyd/UnlimitedSpace.git
-
Install packages
cd ./UnlimitedSpace npm install In windows OS, Open powershell with administrator privileges and run this command, then proceed with bcrypt installation npm install --global --production windows-build-tools
-
Install MongoDB. See guide here.
-
An alternate option is to run Mongo in a Docker container
docker run --name mongodb -p 27017:27017 --rm mongo:4.0.1
-
-
Start MondoDB
mkdir -p ./db/data mongod --dbpath ./db/data --logpath ./db/log
-
Populate MongoDB collections
-
Populate local DB with:
node ./populateDb mongodb://localhost:27017/unlimitedSpaceDb
-
Populate cloud DB with:
node ./populateDb mongodb+srv://dbuser:[email protected]/unlimitedSpaceDb?retryWrites=true
-
-
For local development, start the backend API
npm start
-
And start the frontend
ng serve
-
Connect to frontend: http://localhost:4200/
-
-
username: [email protected]
-
password: testtest
-
-
-
username: [email protected]
-
password: testtest
-
- For local development, we run the frontend and backend as different processes but for the cloud, we run them under a single process or app.
- We have a CD pipeline that builds the angular frontend and deploys the app.
- Our frontend (Angular) is set to connect to localhost by default or relative path ./api when run with the prod argument.
- Our backend (ExpressJS) connects to our cloud DB server using environment variable production when found, otherwise it defaults to MongoDb localhost.
- With this setup, we can do rapid development locally using Angular's dynamic build and reload with
ng serve
, continuously intergrade (push) back to Github and continuously deploy to the cloud and not have to worry about changing server settings.
- main site: https://unlimitedspace.azurewebsites.net/
- API - https://unlimitedspace.azurewebsites.net/api
- Hotel API
- Get all hotels - /hotel
- Get hotel by id - /hotel/id
- Room API
- Get all rooms - https://unlimitedspace.azurewebsites.net/api/room
- Get room by id - https://unlimitedspace.azurewebsites.net/api/room/id
- Get room by hotel - https://unlimitedspace.azurewebsites.net/api/room&hotel=hotelId
- Get room by hotel, sort by price and limit to two results - https://unlimitedspace.azurewebsites.net/api/room&hotel=hotelId&&sort=1&limit=1
- Hotel API