Skip to content

Commit 774c644

Browse files
committed
cloud-functions: add local developmeent documentations
Signed-off-by: bingyuyap <bingyu.yap.21@gmail.com>
1 parent 264610c commit 774c644

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

README.md

+40
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,43 @@ Displays a visualization of the database.
5656
```bash
5757
npm start -w web
5858
```
59+
60+
# Cloud Functions
61+
62+
## Development
63+
64+
### TypeScript
65+
66+
`./cloud_functions` stores the TypeScript Google Cloud Functions.
67+
68+
To add a new function:
69+
70+
1. Create a new file under `./cloud_functions/src`.
71+
> CRON jobs are generally prefixed with `compute`
72+
2. Register new function in `./cloud_functions/src/index.ts`
73+
74+
```ts
75+
export const { newFunction } = require('./newFunction');
76+
77+
functions.http('newFunction', newFunction);
78+
```
79+
80+
To run it locally:
81+
82+
<!-- TODO: Document this -->
83+
84+
1. Make sure to authenticate your GCP account.
85+
2. Update the `start` script in `./cloud_functions/package.json`
86+
```json
87+
{
88+
"scripts": {
89+
// other scripts
90+
"start": "npx functions-framework --target=newFunction [--signature-type=http]",
91+
}
92+
}
93+
```
94+
3. To run the function locally, run in `./cloud_functions`:
95+
96+
```
97+
npm run start
98+
```

0 commit comments

Comments
 (0)