System on firebase functions always have problems that code start.
https://medium.com/@siriwatknp/cold-start-workaround-in-firebase-cloud-functions-8e9db1426bd3
So
google office https://firebase.google.com/docs/functions/networking
const http = require('http'); const functions = require('firebase-functions'); // Setting the `keepAlive` option to `true` keeps // connections open between function invocations const agent = new http.Agent({keepAlive: true}); exports.function = functions.https.onRequest((request, response) => { req = http.request({ host: '', port: 80, path: '', method: 'GET', agent: agent, // Holds the connection open after the first invocation }, res => { let rawData = ''; res.
For logging mulit args with “%O”```
const util = require(‘util’);
function d(…args) {
if (typeof (console) !== ‘undefined’) {
console.log('[Logging]', util.format(…args));
}
}
https://sematext.com/blog/expressjs-best-practices/```
const express = require(‘express’)
const app = express()
const redis = require(‘redis’)
const redisClient = redis.createClient(6379)
async function getSomethingFromDatabase (req, res, next) {
try {
const { id } = req.params;
const data = await database.query()
// Set data to Redis
redisClient.setex(id, 3600, JSON.stringify(data))
res.status(200).send(data) } catch (err) {
console.error(err)
res.status(500)
}
}
function cache (req, res, next) {
const { id } = req.
https://1loc.dev/
In personal setting.json for vs code```
“eslint.workingDirectories”: [
{ “mode”: “auto” }
],
https://www.youtube.com/watch?v=g2nMKzhkvxw
https://www.youtube.com/watch?v=jI4K7L-LI58