Skip to content

Instantly share code, notes, and snippets.

@a7v8x
Created May 2, 2020 12:57
Show Gist options
  • Save a7v8x/6b69771ab21b3476195320619e533edd to your computer and use it in GitHub Desktop.
Save a7v8x/6b69771ab21b3476195320619e533edd to your computer and use it in GitHub Desktop.
import genId from "../lib/gen-id";
import tasks from "../db/tasks-db";
export const createTask = (input) => {
const newTask = {
id: genId(),
...input,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
};
tasks.unshift(newTask);
return newTask;
};
export const getTaskById = id => tasks.find(task => task.id === id)
export const getTasks = () => tasks;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment