-
Notifications
You must be signed in to change notification settings - Fork 0
[WIP] Implement GCP changes for TypeScript #29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
4677751
Initial plan
Copilot 83d93b3
Add GCP Cloud Function support for TypeScript template
Copilot fe372e0
Fix test files for GCP template and verify builds
Copilot 5d57fac
Update README to mark TypeScript GCP as complete
Copilot c996292
Address code review feedback for GCP TypeScript implementation
Copilot 70ff46f
Reduce code duplication and export Azure functions via index.ts
Copilot b2b79ad
Remove yarn.lock from template - generated on install
Copilot 506b8f5
Restore and update yarn.lock with both Azure and GCP dependencies
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| {% if cookiecutter.cloud_service == 'Azure Function App' -%} | ||
| COSMOS_DB_URL=https://your-cosmos-account.documents.azure.com:443/ | ||
| COSMOS_DB_KEY=your-cosmos-db-key | ||
| {%- elif cookiecutter.cloud_service == 'GCP Cloud Function' -%} | ||
| GCP_PROJECT_ID=your-project-id | ||
| FIRESTORE_DATABASE_ID=(default) | ||
| {%- endif %} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
typescript/{{cookiecutter.project_class_name}}/config/inversity.config.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,21 +1,36 @@ | ||
| import "reflect-metadata"; | ||
| import { Container } from 'inversify'; | ||
| {% if cookiecutter.cloud_service == 'Azure Function App' -%} | ||
| import { CosmosClient } from '@azure/cosmos'; | ||
| {%- elif cookiecutter.cloud_service == 'GCP Cloud Function' -%} | ||
| import { Firestore } from '@google-cloud/firestore'; | ||
| {%- endif %} | ||
| import { {{cookiecutter.project_class_name}}Repository } from '@repositories'; | ||
| import { {{cookiecutter.project_class_name}}Controller } from '@controllers'; | ||
| import { {{cookiecutter.project_class_name}}Service, SchemaValidator } from '@services'; | ||
| import { env } from '@models'; | ||
|
|
||
| {% if cookiecutter.cloud_service == 'Azure Function App' -%} | ||
| const client = new CosmosClient({ | ||
| endpoint: env.COSMOS_DB_URL, | ||
| key: env.COSMOS_DB_KEY, | ||
| }); | ||
| {%- elif cookiecutter.cloud_service == 'GCP Cloud Function' -%} | ||
| const client = new Firestore({ | ||
| projectId: env.GCP_PROJECT_ID, | ||
| databaseId: env.FIRESTORE_DATABASE_ID, | ||
| }); | ||
| {%- endif %} | ||
|
|
||
| export const container = new Container({ skipBaseClassChecks: true }); | ||
| container.bind<SchemaValidator>(SchemaValidator).to(SchemaValidator); | ||
| container.bind<{{cookiecutter.project_class_name}}Controller>({{cookiecutter.project_class_name}}Controller).to({{cookiecutter.project_class_name}}Controller); | ||
| container.bind<{{cookiecutter.project_class_name}}Service>({{cookiecutter.project_class_name}}Service).to({{cookiecutter.project_class_name}}Service); | ||
| container.bind<{{cookiecutter.project_class_name}}Repository>({{cookiecutter.project_class_name}}Repository).to({{cookiecutter.project_class_name}}Repository); | ||
| {% if cookiecutter.cloud_service == 'Azure Function App' -%} | ||
| container.bind<CosmosClient>(CosmosClient).toConstantValue(client); | ||
| {%- elif cookiecutter.cloud_service == 'GCP Cloud Function' -%} | ||
| container.bind<Firestore>(Firestore).toConstantValue(client); | ||
| {%- endif %} | ||
|
|
||
| export default container; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are you sure this is how http cloud functions are configured in gcp?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is the correct configuration for GCP Cloud Functions (2nd gen). The functions are exported individually and referenced via the index.ts file. Added proper index.ts that exports all functions, and configured package.json main entry point to dist/index.js for GCP. The start script uses functions-framework with --target to specify which function to run locally. (commit: 39d0e6c)