Project template·Pro
Express + SQLite tasks API
A tasks API on Express 5 with filtering, paging and tests. Data goes to node:sqlite, so nothing native has to compile. It needs the Linux environment with Node.js 22.13 or newer, and npm install fetches about 3.5 MB.
You need PocketCode Pro to install it.
If PocketCode is installed on your Android device, this opens the page in the app.
Preview
Files
README.md
package-lock.json
package.json
server.js
src/app.js
src/db.js
src/errors.js
src/routes/tasks.js
src/validate.js
test/tasks.test.jsREADME.md
# Tasks API: Express + SQLite A REST API for tasks with Express 5 and SQLite: create, list, read, update and delete tasks, filter the list by state, tag or text, and page through it. Input is checked and errors come back as JSON. The database is `node:sqlite`, which is built into Node.js 22.13 and newer, so the only package is Express (about 65 small packages, 3.5 MB, all JavaScript). Comes with tests. ## Run it in PocketCode You need the app's Linux environment with Node.js 22.13 or newer and npm (the Developer pack in Terminal › Linux includes both). Check with `node --version`. 1. Open the terminal in this project's folder (Open Terminal Here, in the editor menu). 2. Install Express (needs internet the first time): ```sh npm install ``` 3. Start the server: ```sh npm start ``` The terminal shows `Tasks API on http://localhost:3000`. `npm run dev` does the same and restarts it when you save a file. Some Node.js versions also print `ExperimentalWarning: SQLite is an experimental feature`; the API works the same. 4. Open http://localhost:3000 in the DevBrowser (or in the phone's browser) to see the list of endpoints. To try the API, open a second terminal tab: ```sh curl -X POST localhost:3000/api/tasks -H 'content-type: application/json' -d '{"title":"Buy milk","tag":"home"}' curl 'localhost:3000/api/tasks?done=false' curl -X PATCH localhost:3000/api/tasks/1 -H 'content-type: application/json' -d '{"done":true}' ```This preview is shortened. You get the full content when you install it.
Changes in 1.0.0
First version.