Skip to content

Commit a62e8b8

Browse files
committed
Add comments to the function handler and tweak readme
1 parent e9ace15 commit a62e8b8

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

api/index.js

+5
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,21 @@ const serverlesswp = require('serverlesswp');
33
const { validate } = require('../util/install.js');
44
const { setup } = require('../util/directory.js');
55

6+
// This is where all requests to WordPress are routed through. See vercel.json or netlify.toml for the redirection rules.
67
exports.handler = async function (event, context, callback) {
8+
// Move the /wp directory to /tmp/wp so that it is writeable.
79
setup();
810

11+
// Send the request (event object) to the serverlesswp library. It includes the PHP server that allows WordPress to handle the request.
912
let response = await serverlesswp({docRoot: '/tmp/wp', event: event});
13+
// Check to see if the database environment variables are in place.
1014
let checkInstall = validate(response);
1115

1216
if (checkInstall) {
1317
return checkInstall;
1418
}
1519
else {
20+
// Return the response for serving.
1621
return response;
1722
}
1823
}

readme.md

+16-8
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,30 @@
1-
# WordPress On Vercel, Netlify, or AWS
2-
Serverless WordPress on Vercel, Netlify, or AWS Lambda.
1+
# Run WordPress On Vercel, Netlify, or AWS
2+
Serverless WordPress on Vercel, Netlify, or AWS Lambda because WordPress hosting is silly.
33

44
| Vercel (recommended) | Netlify |
55
| --- | --- |
66
| [![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fmitchmac%2Fserverlesswp&env=DATABASE,USERNAME,PASSWORD,HOST&envDescription=Database%20credentials%20from%20PlanetScale%20or%20other%20host&envLink=https%3A%2F%2Fgithub.com%2Fmitchmac%2FServerlessWP%23setup-vercel-or-netlify&project-name=serverlesswp&repository-name=serverlesswp) | [![Deploy to Netlify](https://www.netlify.com/img/deploy/button.svg)](https://app.netlify.com/start/deploy?repository=https://github.com/mitchmac/serverlesswp) |
77

88
## Project Goals
99

10-
Easy onboarding: deploy with one of the links above and then setup a database
10+
Maintaining servers for WordPress can be a pain. Serverless hosting should be less work.
1111

12-
Keep costs low (often free) for the majority of small WordPress websites
12+
Small WordPress sites shouldn't cost much (or anything) to host.
1313

14-
Ability to use most WordPress plugins and themes
14+
Deploying WordPress should be easy. Setup a database and try one of the links above.
1515

16-
Take advantage of edge caching for blazing fast page loads
16+
WordPress plugins and themes save time and should be extensively supported.
1717

18-
Reduce the carbon footprint of WordPress websites
18+
Edge caching can give us blazing fast websites.
1919

20-
✅ A helpful community. [Share your successes, knowledge, ideas, or struggles](https://github.com/mitchmac/ServerlessWP/discussions) in the discussions
20+
✅ We can reduce the carbon footprint of WordPress websites.
21+
22+
✅ We can create a helpful community. [Share your successes, knowledge, ideas, or struggles](https://github.com/mitchmac/ServerlessWP/discussions) in the discussions.
2123

2224
## Setup (Vercel or Netlify)
25+
26+
**Please note this is currently an experimental project and shouldn't be used for websites with considerable security or stability requirements.**
27+
2328
1. Create a MySQL database that can be accessed from Vercel or Netlify. The easiest way to do this is with [PlanetScale](https://planetscale.com/) which has a free tier to get started. When using PlanetScale, make sure your database's region matches the region that Vercel or Netlify will use. This is usually ```us-east-1```.
2429
2. Deploy this repository to Vercel or Netlify. One of the links above will get you started. You'll just need a GitHub account.
2530
3. Update the environment variables for your project in Vercel or Netlify with the database credentials. These are used by wp-config.php. The environment variables are:
@@ -50,6 +55,9 @@ S3_ACCESS_KEY
5055
2. Clone the repository and run `serverless deploy` to confirm that the Lambda is created
5156
3. Like step 2 above, create a MySQL database and update the environment variables. They can be updated in the `serverless.yml` file and then run `serverless deploy` again.
5257

58+
## Getting help
59+
Need help getting ServerlessWP installed? [Start a discussion](https://github.com/mitchmac/ServerlessWP/discussions) or [e-mail me](mailto:[email protected])
60+
5361
## How can you help?
5462
- Just using ServerlessWP and [reporting any problems you experience](https://github.com/mitchmac/ServerlessWP/issues) is a fantastic way to help!
5563
- Share the word! Let's try to make WordPress hosting better.

0 commit comments

Comments
 (0)