diff --git a/.prettierrc b/.prettierrc index 0852ba2..fa9699b 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,7 +1,7 @@ { - "semi": true, - "trailingComma": "all", - "singleQuote": true, - "printWidth": 80, - "tabWidth": 2 - } \ No newline at end of file + "semi": true, + "trailingComma": "all", + "singleQuote": true, + "printWidth": 80, + "tabWidth": 2 +} diff --git a/.vscode/settings.json b/.vscode/settings.json index ca0e6ac..c4f57de 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,20 +1,20 @@ { - "editor.defaultFormatter": "esbenp.prettier-vscode", - "[javascript]": { - "editor.defaultFormatter": "esbenp.prettier-vscode" - }, - "[javascriptreact]": { - "editor.defaultFormatter": "esbenp.prettier-vscode" - }, - "[typescript]": { - "editor.defaultFormatter": "esbenp.prettier-vscode" - }, - "[typescriptreact]": { - "editor.defaultFormatter": "esbenp.prettier-vscode" - }, - "prettier.configPath": "./.prettierrc", - "editor.formatOnSave": true, - "[jsonc]": { - "editor.defaultFormatter": "vscode.json-language-features" - }, - } \ No newline at end of file + "editor.defaultFormatter": "esbenp.prettier-vscode", + "[javascript]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[javascriptreact]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[typescript]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[typescriptreact]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "prettier.configPath": "./.prettierrc", + "editor.formatOnSave": true, + "[jsonc]": { + "editor.defaultFormatter": "vscode.json-language-features" + } +} diff --git a/README.md b/README.md index 7e5e9bf..0491bac 100644 --- a/README.md +++ b/README.md @@ -8,9 +8,9 @@ This is important because Single Page Applications expose any secrets they are b I use certbot to create the https certifications -```sudo yum install -y certbot``` +`sudo yum install -y certbot` -```sudo certbot certonly --standalone -d api.peterwalker.xyz``` +`sudo certbot certonly --standalone -d api.peterwalker.xyz` I run this process in the background of my EC2 server using -```sudo pm2 start server.js``` +`sudo pm2 start server.js` diff --git a/server.js b/server.js index 88cd3ce..3d92084 100644 --- a/server.js +++ b/server.js @@ -8,9 +8,11 @@ const dotenv = require('dotenv'); dotenv.config(); // Use CORS middleware to allow requests from all origins -app.use(cors({ - origin: 'https://peterwalker.xyz', -})); +app.use( + cors({ + origin: 'https://peterwalker.xyz', + }), +); // Store your API key securely in an environment variable const API_KEY = process.env.API_KEY || 'API_KEY not defined'; @@ -35,11 +37,10 @@ app.get('/api/key', (req, res) => { const options = { key: fs.readFileSync('/etc/letsencrypt/live/api.peterwalker.xyz/privkey.pem'), cert: fs.readFileSync('/etc/letsencrypt/live/api.peterwalker.xyz/cert.pem'), - ca: fs.readFileSync('/etc/letsencrypt/live/api.peterwalker.xyz/chain.pem') + ca: fs.readFileSync('/etc/letsencrypt/live/api.peterwalker.xyz/chain.pem'), }; // Start the HTTPS server https.createServer(options, app).listen(PORT, () => { console.log(`HTTPS Server is running on port ${PORT}`); }); -