The recent hot,

  • I worked on Vue3’s Composition Api all night to get a better understanding of it (700+ likes)
  • One-click decompile wechat applets to get the source code, and convert it into UniApp or taro cross-end projects
  • Present “Virtual Programmer Encourager” to the 1024 Programmer Festival, where architects gather!

Here we go. This long, long, long, long, long…

What is cloud development

When it comes to cloud development, let’s first look at what prerequisites we, as full-stack engineers, need to master and complete before we can write a business without cloud development.

  • A server or virtual space
  • Domain name (Parse, record, and HTTPS certificates)
  • Installing the server environment (python/php/nginx/apache/redis/node)
  • Database (mysql/nosql/mongodb)

Now that this is over, we can start writing business code…

But it’s not just writing code. If you do it yourself, you need to know a lot about operations…

. Young people don’t talk about martial morality

Serverless lets you skip the above mess

Focus on the five strokes of lightning…

Ah… not

Cloud development allows us to focus on business logic development

Wechat applets cloud development

Wechat Small program launched the wechat small program cloud development mode at the end of 2018. I also participated in the WeGeek hackathon that year and won the 5th place. Ahem…

Due to the numerous independent developers in the wechat ecosystem, the small program cloud development mode and so directly hit the pain point of independent developers, I believe that many developers have already applied cloud development in the product.

  • Will not the wool like this smell good when pulled up?

Precautions for Opening

You cannot use test numbers, you must register an Appid yourself.

New cloud development project will default to a new cloud development demo project, which demonstrates in detail how to use the various capabilities of cloud development, we go to see the document, here is not unnecessary to gather up words.

Wechat applets cloud development document

In this paper, case

We use cloud development to make a drawing solitaire message board

Message board UI setup

drawing

Cloud storage

  • Canvas to temporary file to Base64
wx.canvasToTempFilePath({
  canvasId: 'myCanvas'.success: function (res) {
    wx.cloud.callFunction({
      name:"painterbbs".data: {act:"post".file:wx.getFileSystemManager().readFileSync(res.tempFilePath,"base64")},success:(result) = >{
        wx.hideLoading();
        console.log(result);
        that.setData({
          painterIsShow: false}); }}); }})Copy the code
  • The cloud function receives the parameters and uploads them to the cloud storage
let res = await cloud.uploadFile({
  cloudPath:"painterbbs/"+wxContext.OPENID+Date.now()+".png".fileContent:Buffer.from(event.file, 'base64')});Copy the code

Cloud database

submit

db.collection("painterbbs").add({
  data: {openid:wxContext.openid,
    fileid:res.fileID
  }
});
Copy the code

read

const res = await db.collection("painterbbs") .skip(event.page? event.page:0)
  .limit(10)
  .get();

return res;
Copy the code

delete

const res = await db.collection("painterbbs").doc(event.id).remove();

return res;
Copy the code

Download the source code

Github.com/ezshine/wxc…

conclusion

Originally, we were going to make a feature like this, either by mastering all the hassles we wrote in front of us, or by working with the backend engineers. Now with cloud development Serverless, we can easily complete business modules independently. For the foreseeable future, front end engineers and back end engineers will merge…

Pay attention to the big handsome doing full stack


  • This is our team’s open source project, Element3
  • A front-end component library that supports VUE3


🏆 issue 7 | all things can be Serverless technology projects