A simple web application that provides CRUD operations for bookings. Exposes a REST API with NodeJS and MongoDB, while the front-end is written in Angular.
Built with:
- NodeJS
- Angular 5
- MongoDB
To run the app, clone the repository and cd into the directory. Then run:
yarn install && yarn start
This will build the Angular project and start a development server on http://localhost:3000/. The REST API will be available at /api/bookings. It will use the MongoDB database available locally, default port 27107 and uses a collection called bookings.
The project is using dotenv to manage environment variables. If you want to provide a custom MongoDB database or REST API endpoint, create a .env file in the root of the directory (it is ignored by git).
If you are using a MongoDB database that requires users to sign in, you must create the .env file in the root of your project and add the Mongo URI, as specified below.
Add the following lines:
API_URL=http://localhost:3000/api
MONGO_URL=mongo://username:password@mongohost:port/database
The API_URL points to the NodeJS server. Defaults to http://localhost:3000/api if not present. The MONGO_URL points to the MongoDB instance and database where all bookings are stored.
There's a development option, where you can have both the Angular CLI and NodeJS running at the same time. Have a look at package.json for more details.
The project uses Jest for testing both Angular and NodeJS components. To run all tests, type:
yarn test
or simply
jest
There's a development option to "watch" for changes and run all tests while you implement features:
yarn test:watch
Here are a few articles that helped me set some things up: