Serverless Fullstack Application

This is a template of serverless fullstack application. It aims to be the simplest possible way to build a serverless fullstack application, including a Vue.js application on the front-end bundled with Parcel and back-end API.

This template includes:

 

  1. Prepare
  2. Download
  3. Bootstrap
  4. Deploy
  5. Development

 

Prepare

Before all below steps, you should install Serverless Framework globally:

$ npm i serverless -g

Download

Severless cli is very convenient, it can download templates in any github project which should contain serverless.yml file.

$ serverless create --template-url https://github.com/yugasun/fullstack-application-postgres

Bootstrap

Copy .env.example file to .env in project root:

Add the access keys of a Tencent CAM Role with AdministratorAccess in the .env file, like below:

# .env
TENCENT_SECRET_ID=xxx
TENCENT_SECRET_KEY=xxx
TENCENT_APP_ID=xxx

Install the NPM dependencies:

$ npm run bootstrap

Deploy

Deploy via the serverless command:

$ serverless

Use the --debug flag if you'd like to learn what's happening behind the scenes:

$ serverless --debug

Notice: After deploy success, please copy the postgressql private url to api/.env file.

Development

After your first deployment, you will be able to run the frontend locally and have it communicate to the live backend in the cloud.

$ cd frontend && npm run start

Notice

Because this project integrated cloud db connection, you should create a mysql instance on tencent cloud, please refer to official docs:

中文

After you create a mysql instance, you should create a .env file in api folder, and set all required parameters like .env.example.

License

MIT