Skip to content

Latest commit

 

History

History
166 lines (126 loc) · 3.89 KB

CONTRIBUTING.md

File metadata and controls

166 lines (126 loc) · 3.89 KB

Files structure

Website                            Description
wc-front-end Front-end SPA of the app, Written in VueJS
src Back-end API, Written in Typescript
dist Compiled code to Javascript of the API server

Init the project in local env

Note : Front-end and the Back-end are deployed separately (vercel-heroku).

There are some of the configurations related to cors

Clone the repo

git clone https://github.com/mouadTaoussi/checkwebsite.git
cd webcheck

Install the dependencies

npm install

Create .env file and add those elements within your credentiels below:

But before that, you need to generate vapid keys for use in webpush protocol

web-push generate-vapid-keys [--json]

If it didn't work try this command

``` ./node_modules/.bin/web-push generate-vapid-keys ```
touch .env && nano .env
EMAIL = xxxxxxxxxxxxxxxxxx
PASSWORD = xxxxxxxxxxxxxxx
DATABASE_CONNECTION = xxxx
VAPID_PUBLIC_KEY = xxxxxxx
VAPID_PRIVATE_KEY = xxxxxx
PORT_DEV = 8000
INDEV = development
JWT_SECRET = xxxxxxxxxxxxx

Edit main.config.ts file

You must edit this file to specify the front end origin (where you deployed the front end app) that's allowed to access your backend server.

nano src/main.config.ts
const application_config : Config  = {
	email                : process.env.EMAIL,
	password             : process.env.PASSWORD,
	database_connection  : process.env.DATABASE_CONNECTION,
	vapid_public_key     : process.env.VAPID_PUBLIC_KEY,
	vapid_private_key    : process.env.VAPID_PRIVATE_KEY,
	port_dev             : process.env.PORT_DEV,
	port                 : process.env.PORT,
	jwt_secret           : process.env.JWT_SECRET,
	// Edit those :
	// front_end_origin     : "http://localhost:8080", <-- if you are in local development
	// front_end_origin     : "*", <-- if you allowed all origins accecing your back-end server
	// front_end_origin     : "https://yourfrontendappdomain.com", <-- if you deployed the frontend to a different hosting service
	// front_end_origin     : "/", <-- if your frontend app and the back-end server are in the same host
	websites_limit       : 6,
}

if you deployed the front-end and the back-end to same host

uncomment that code in main.ts file:

app.use('/',express.static(  __dirname + "/../wc-front-end/dist"));

then comment out this snippet below:

// app.get('/',(req:Request, res:Response)=>{
//	res.redirect('https://webcheck.vercel.app');
// });

compile the code

npm run compile

run app locally

npm run dev

run app when it is in prod

npm run start

Front-end setup

cd wc-front-end
npm install

Edit api.config.js

nano api.config.js
const api_config = {
	apiPath   : "https://yourbackendappdomain.com/"  // API Origin <SERVER SIDE ENDPOINT> 
	// apiPath   : "http://localhost:8000/" <-- if your app in local env
	// apiPath   : "/" <-- if your frontend app and the back-end server are in the same host
}

Compiles and hot-reloads for development

npm run serve

Compiles and minifies for production

npm run build

Run your unit tests

npm run test:unit

Lints and fixes files

npm run lint

Note: You can use this library to run those servers concurrently

Instead of opening up multiple terminal tabs to run compiling and the server and the front-end proccesses

Customize configuration

See Configuration Reference.