This project is a website which can help you cook by at term giving exemple of receipes and meals based on a number of required Kcal or other nutriments such as protein, salt, etc...
You need to have these programs installated in order for the front end to work succesfully :
- @Angular/cli installed globaly (Works with Angular cli V11.0.5)
- NodeJS with npm (Works with NodeJS V16.14)
The files environment.ts
and environment.prod.ts
are used respectively for development and production build. They contains the following keys :
apiURL
- The API Url used in the application to request receipes, users, favorites etc...apiDomain
- The domain name where the API is deployed to be used as a whitelisted domain to be used with user's bearer tokens
- First, go in the
Front/
folder - Then type
npm install
to get the needed dependencies - You can start the webserver with the
ng serve
command. The server will be accessible athttp://localhost:4200/
. Note that this is a dev server. - To build all the necessary files for production use the command
ng build --prod
and look inside thedist/
folder.
It is a web rest API used by the front-end to interact with the database. It has many security build in (SSL, CORS, Authentication, API Key, etc...) with any methods needed by the application.
You need to have these programs installated in order for the back end to work succesfully :
- MongoDB (Works with MongoDB 4.2.6)
- NodeJS with npm (Works with NodeJS V16.14+)
Create a .env
file containing the following keys :
SSL_CERTIFICATE_PASSPHRASE
- The passphrase used to create the self signated certificate for HTTPS supportJWT_TOKEN_SECRETKEY
- Secret key used to generate json web tokens for users account in the appJWT_TOKEN_TTL
- The number of seconds before a generated JWT expires.MONGO_URI
- The MongoDB URI to connect to (Format :mongodb://IP_ADDRESS:PORT_NUMBER/DATABASE_NAME
)
- Install OpenSSL by clicking on this link
- Open a CMD/Bash window
- Check if OpenSSL is installed with this command line :
openssl version
- If this works then type this command line :
openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365
- You will have to type some informations in order to signate the certificate then put a passphrase
- You should have two new files :
cert.pem
andkey.pem
- You need to put the previous typed passphrase in the environment variable :
SSL_CERTIFICATE_PASSPHRASE
which is located in the.env
file.
We are using a free dataset from internet to add receipies to our project it can be found in data/data.json
.
It is automaticaly added to the database at the start of the app for the first time or if the receipes
collection is removed.
Documentation about the API can be found at https://localhost:8443/api/v1/docs/
CORS is a middleware that will allow (or not) a request if it is sent by another domain that the one in which API is running.
In our case the file whitelist.json
needs to be updated to integrate any domain that will request the API (the front's domain for example)
The bin/
folder contains two different files www
and wwws
both used to start the web serveur but each in its own way.
wwws
is used to start a SSL secured webserver (HTTPS) using cert.pem
certificate along with the Rsa key key.pem
. Those two files are generated using the OpenSSL section of this document.
www
is used to start a basic unsecured webserver (HTTP), we will mainly use this file to deploy on production builds and in docker / kubernetes containers.
//TODO
- First, go in the
Webservice/
folder - Then type
npm install
to install the requiered dependencies - You can start your server with
npm run start
and open a new web browser and type :http://localhost:8080
in a browser and you should be redirected to your HTTPS project (https://localhost:8443
) - Congrats ! Your HTTPS Support works 👍