See the application structure in the image below:
This is the Backend application. For the Frontend application, please go to https://github.com/leogomesdev/sunshine-frontend
This project provides APIs for the frontend application.
- Express version 4, a minimalist web framework for Node.js
- MongoDB as database
- Mongoose for database connection
- REST API
- TypeScript, JavaScript with syntax for types
- Jest for unit tests
- Commitizen command line tool
- Conventional Commits specification
- Node.js (v18)
- npm
- MongoDB database. Highly recommended to Deploy a Free Cluster at MongoDB Atlas
- Install Docker Desktop
- Clone both repositories: sunshine-frontend and sunshine-backend
- Access the root folder for one of the projects
- Run:
docker-compose up
- This command will create and run 3 containers:
- db: a MongoDB local instance
- api: the sunshine-backend project
- app: the sunshine-frontend project
-
Be sure to install the requirements
- If you have nvm - Node Version Manager installed, you could just run
nvm install
and it will install the correct version of Node.js based on file.nvmrc
- If you have nvm - Node Version Manager installed, you could just run
-
Create the .env file:
cp -v .env.example .env
-
Edit the .env file to provide the required environment variables.
-
Install dependencies:
npm install
-
Start the application:
npm run start
🔎 Check the API documentation available at swagger (OpenAPI 3.0)
- Using Postman, go to the menu Files > Import and import the file Sunshine.postman_collection.json, available in the docs folder
- After importing, the API Collection will be available on the left:
- The baseUrl variable is already defined on the Variables tab
- It is possible to use MongoDB Compass to check the data on the sunshine database, on users collection.
- In the example below, the connection string is the required address when running this project with docker-compose:
mongodb://localhost:27018/sunshine
# unit tests
npm run test