Skip to content

Instantly share code, notes, and snippets.

@ezzabuzaid
Created July 30, 2024 07:58
Show Gist options
  • Save ezzabuzaid/6d65224d9127b511672aa24106180877 to your computer and use it in GitHub Desktop.
Save ezzabuzaid/6d65224d9127b511672aa24106180877 to your computer and use it in GitHub Desktop.
projectName extensions
HTTP trigger project
core,identity,hono,fly,postgresql,google-cloud-storage
export default project(
  feature('blogs', {
    workflows: [
      workflow('UploadSingleFileWorkflow', {
        tag: 'tasks',
        trigger: trigger.http({
          method: 'post',
          path: '/:id',
        }),
        output: output('return {file: steps.fileUrl}'),
        actions: {
          uploadFile: action.googleCloudStorage.uploadSingle({
            outputName: 'fileUrl',
          }),
          setPostCover: action.database.set({
            columns: [useField('cover', '@workflow:fileUrl')],
            table: useTable('posts'),
            query: query(where('id', 'equals', '@trigger:path.id')),
          }),
        },
      }),
    ],
    tables: {
      posts: table({
        fields: {
          title: field({ type: 'short-text' }),
          cover: field({ type: 'url' }),
        },
      }),
    },
  }),
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment