projectName | extensions |
---|---|
Todo project |
core,identity,hono,fly,postgresql |
Last active
August 13, 2024 12:36
-
-
Save ezzabuzaid/a43d626f2b1d974943841b187782fe1a to your computer and use it in GitHub Desktop.
january-todo.md
This file contains 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
{ | |
"projectName": "Todo API", | |
"title": "Todo API", | |
"description": "A simple API for managing todos", | |
"extensions": ["core", "identity", "postgresql", "hono", "fly"], | |
"sourceCode": "", | |
"author": { | |
"name": "January", | |
"url": "https://github.com/JanuaryLabs" | |
} | |
} |
This file contains 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
export default project( | |
feature('Todo', { | |
tables: { | |
tasks: table({ | |
fields: { | |
title: field({ type: 'short-text', validations: [mandatory()] }), | |
completed: field({ type: 'boolean' }), | |
}, | |
}), | |
}, | |
workflows: [ | |
workflow('AddTaskWorkflow', { | |
tag: 'tasks', | |
trigger: trigger.http({ | |
method: 'post', | |
path: '/', | |
}), | |
actions: { | |
addTask: action.database.insert({ | |
table: useTable('tasks'), | |
columns: [useField('title', trigger.body.title)], | |
}), | |
}, | |
}), | |
workflow('UpdateTaskWorkflow', { | |
tag: 'tasks', | |
trigger: trigger.http({ | |
method: 'patch', | |
path: '/:id', | |
}), | |
actions: { | |
updateTask: action.database.set({ | |
table: useTable('tasks'), | |
columns: [useField('title', true)], | |
query: query(where('id', 'equals', trigger.path.id)), | |
}), | |
}, | |
}), | |
workflow('ListTasksWorkflow', { | |
tag: 'tasks', | |
trigger: trigger.http({ | |
method: 'get', | |
path: '/', | |
}), | |
actions: { | |
listTasks: (trigger) => | |
action.database.list({ | |
table: useTable('tasks'), | |
pagination: 'deferred_joins', | |
limit: 20, | |
query: query(where('id', 'equals', trigger.path.id)), | |
}), | |
}, | |
}), | |
], | |
}) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment