To build and run this app locally you will need a few things:
- Clone the repository
git clone https://github.com/tahagoal/MustalaTask
- Create a new DB called
Gateways
- Run Mongo db on
mongodb://localhost:27017/Gateways
, as provided onBack/config/default.json
- Install dependencies
cd <project_name>/Back
npm install
- Build and run the backend project with auto reload (nodemon)
npm run server
- Build and run the project
npm run start
Finally, navigate to http://localhost:5050/
and you should see the API running!
All the different build steps are orchestrated via npm scripts.
Npm scripts basically allow us to call (and chain) terminal commands via npm.
This is nice because most JavaScript tools have easy to use command line utilities allowing us to not need grunt or gulp to manage our builds.
If you open package.json
, you will see a scripts
section with all the different scripts you can call.
To call a script, simply run npm run <script-name>
from the command line.
You'll notice that npm scripts can call each other which makes it easy to compose complex builds out of simple individual build scripts.
Below is a list of all the scripts this template has available:
Npm Script | Description |
---|---|
tsc |
Transpiles TypeScript codes to JavaScript. |
watch-tsc |
Transpiles TypeScript codes to JavaScript, with auto reload. |
deploy |
Runs node on dist/server.js which is the app's entry point. |
watch-deploy |
Runs node on dist/server.js which is the app's entry point, with auto reload. |
server |
Transpiles TypeScript codes to JavaScript then run node on dist/server.js with auto reload. |
start |
Transpiles TypeScript codes to JavaScript then run node on dist/server.js . |
Since we're developing with TypeScript, it is important for the codes to be transpiled first to JavaScript before running the node server. It is best to deploy the app using: npm run server
or npm run start
command.
Attached postman collection to test the APIs without using the UI. Includes 5 APIs
GET: http://localhost:5050/api/gateways
GET: http://localhost:5050/api/gateways/6109473dfd8bfc9fccf4fe73
GET: http://localhost:5050/api/devices/6107154c311d462d1c1d0d2c
POST: http://localhost:5050/api/gateways
POST: http://localhost:5050/api/devices
DELETE: http://localhost:5050/api/devices/61080270311d462d1c1d0de5
cd <project_name>/Front
npm install
This project was generated with Angular CLI version 10.1.4.
Run ng serve
for a dev server. Navigate to http://localhost:4200/
. The app will automatically reload if you change any of the source files.
Run ng generate component component-name
to generate a new component. You can also use ng generate directive|pipe|service|class|guard|interface|enum|module
.
Run ng build
to build the project. The build artifacts will be stored in the dist/
directory. Use the --prod
flag for a production build.
To get more help on the Angular CLI use ng help
or go check out the Angular CLI README.
Just run the file automated-build.sh
and ti will install all npm packages and make the dist
folder for both front and backend.