Skip to content

Instantly share code, notes, and snippets.

@ezzabuzaid
Last active August 13, 2024 12:36
Show Gist options
  • Save ezzabuzaid/a43d626f2b1d974943841b187782fe1a to your computer and use it in GitHub Desktop.
Save ezzabuzaid/a43d626f2b1d974943841b187782fe1a to your computer and use it in GitHub Desktop.
january-todo.md
{
"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"
}
}
projectName extensions
Todo project
core,identity,hono,fly,postgresql
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