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 |
There are some of the configurations related to cors
git clone https://github.com/mouadTaoussi/checkwebsite.git
cd webcheck
npm install
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
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,
}
app.use('/',express.static( __dirname + "/../wc-front-end/dist"));
// app.get('/',(req:Request, res:Response)=>{
// res.redirect('https://webcheck.vercel.app');
// });
npm run compile
npm run dev
npm run start
cd wc-front-end
npm install
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
}
npm run serve
npm run build
npm run test:unit
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