Skip to content

Instantly share code, notes, and snippets.

@ezzabuzaid
Last active July 30, 2024 07:48
Show Gist options
  • Save ezzabuzaid/174d1a48e710d090ea1fd051dac723f2 to your computer and use it in GitHub Desktop.
Save ezzabuzaid/174d1a48e710d090ea1fd051dac723f2 to your computer and use it in GitHub Desktop.
projectName extensions
Firebase Authentication
core,identity,hono,fly,postgresql,firebase-auth
export default project(
  feature('products', {
    policies: {
      isAuthenticated: policy.authenticated(),
    },
    tables: {
      products: table({
        fields: {
          name: field({
            type: 'short-text',
            validations: [
              mandatory({
                message: 'Name is missing.',
              }),
            ],
          }),
        },
      }),
    },
    workflows: [
      workflow('CreateProductWorkflow', {
        tag: 'products',
        trigger: trigger.http({
          path: '/',
          method: 'post',
          policies: ['isAuthenticated'],
        }),
        actions: {
          insertProduct: action.database.insert({
            outputName: 'product',
            table: useTable('products'),
            columns: [useField('name', '@trigger:body.name')],
          }),
        },
      }),
    ],
  }),
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment