We think you might be interested in this job:

https://deno.land/ is a V8-based, Rust-built runtime for JavaScript and TypeScript. Moreover, it supports (and encourages) development in TypeScript out of the box, https://www.typescriptlang.org/ and makes it easier to catch errors while developing.

This means the runtime can't access the environment variables, the file system, or the network without the developer giving explicit permission.

In your tasks.ts file, add the following method below your getAllTasks method: export const createTask: HandlerFunc = async (ctx: Context) => { const { description } = (await ctx.body) as Task; const newTask: Task = { id: crypto.randomUUID(), description, createdDate: new Date(), complete: false, completedDate: null }; const tasks = JSON.parse(await Deno.readTextFile("./tasks.json")) as Task[]; const newTasks = [...tasks, newTask]; await Deno.writeTextFile("./tasks.json", JSON.stringify(tasks)); return ctx.json(newTask, 200); }

To add the functionality previously listed to the module, add the following code to your tasks.ts file: export const completeTask: HandlerFunc = async (ctx: Context) => { const { id } = ctx.params; const { complete } = (await ctx.body) as Task; const tasks = await readTasks(); const index = tasks.findIndex(t => t.id == id); if (index === -1) { return ctx.json({ message: "Task not found"}, 404); } tasks[index].complete = complete; tasks[index].completedDate = complete ?

Related Articles