beardofedu / beardofedu/copilot-cli-fun-times

feat: persistent JSON file storage (replace in-memory array)

Open
#10 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
JavaScript
Stars
1
Forks
0
PR merge metrics
No merged PRs in 30d

Description

## Summary
Replace the in-memory `tasks` array with a simple JSON file store so that task data survives server restarts.

## Motivation
All task data is currently lost whenever the server process stops. A file-backed store is the simplest path to persistence without introducing a full database dependency, and it keeps the project easy to run locally.

## Proposed Behavior
- Task data is read from `data/tasks.json` on server startup
- Every mutating operation (create, update, delete) writes the updated array back to disk atomically (write to a temp file then rename)
- If `data/tasks.json` does not exist, the server initializes with the existing seed data and creates the file
- All read/write operations are wrapped in a `storage.js` module that exports `readTasks()` and `writeTasks(tasks)`
- Route handlers call the storage module instead of mutating the in-memory array directly

## Acceptance Criteria
- [ ] `src/storage.js` module exported with `readTasks()` and `writeTasks(tasks)` functions
- [ ] Server loads tasks from `data/tasks.json` at startup; creates file with seed data if missing
- [ ] All CRUD routes use `storage.js` instead of the in-memory array
- [ ] Server restart preserves all previously created/updated/deleted tasks
- [ ] `data/tasks.json` is listed in `.gitignore`
- [ ] Unit tests for the storage module mock the filesystem (no real file I/O in tests)

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by tracing the current in-memory tasks array and the CRUD route handlers, then add the mentioned src/storage.js entry points and inspect .gitignore. Use the storage requirements and data/tasks.json behavior as the completion checklist, including atomic writes, seed initialization, restart persistence, and filesystem-mocked unit tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.